source: vendor/bash/3.1-p17/examples/functions/seq

Last change on this file was 3228, checked in by bird, 18 years ago

bash 3.1

File size: 528 bytes
Line 
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}
Note: See TracBrowser for help on using the repository browser.