1# Generate a sequence from m to n, m defaults to 1. 2 3seq () 4{ 5 declare -i lo hi i # makes local 6 local _SEQ 7 8 case $# in 9 1) seq 1 "$1" ; return $? ;; 10 2) lo=$1 hi=$2 11 i=$lo _SEQ="" 12 while let "i <= hi"; do 13 _SEQ="${_SEQ}$i " 14 let i+=1 15 done 16 echo "${_SEQ# }" 17 return 0 ;; 18 *) echo seq: usage: seq [low] high 1>&2 ; return 2 ;; 19 esac 20} 21 22# like the APL `iota' function (or at least how I remember it :-) 23iota() 24{ 25 case $# in 26 1) seq 1 "$1"; return $?;; 27 *) echo "iota: usage: iota high" 1>&2; return 2;; 28 esac 29} 30