source: trunk/third/bash/examples/functions/seq @ 12959

Revision 12959, 528 bytes checked in by tb, 26 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r12958, which included commits to RCS files with non-trunk default branches.
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.