From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail.clark.net ([168.143.0.10]) by hawkwind.utcs.utoronto.ca with SMTP id <24653>; Thu, 1 May 1997 21:17:24 -0400 Received: from clark.net (culliton@explorer.clark.net [168.143.0.7]) by mail.clark.net (8.8.5/8.6.5) with ESMTP id RAA11658 for ; Thu, 1 May 1997 17:39:50 -0400 (EDT) From: Tom Culliton Received: (from culliton@localhost) by clark.net (8.8.5/8.7.1) id RAA07113 for rc@hawkwind.utcs.toronto.edu; Thu, 1 May 1997 17:40:10 -0400 (EDT) Date: Thu, 1 May 1997 17:40:10 -0400 Message-Id: <199705012140.RAA07113@clark.net> To: rc@hawkwind.utcs.toronto.edu Subject: Speaking of counting... Does anyone have a nice little generic range function for rc? The type of thing that lets generate a list something like the indices from a fortran or basic for statement. (I'm actually modelling this after the one in python.) 1 argument means for (i = 0; i < $1; i += 1) 2 arguments mean for (i = $1; i < $2; i += 1) 3 arguments mean for (i = $1; ($3 > 0 && i < $2) || ($3 > 0 && i > $2; i += $3) For example... # echo 99 down to but not including 0 for (i in `{range 99 0 -1}) echo $i # echo 0 up to but not including 10 for (i in `{range 0 10}) echo $i # echo 0 up to but not including 10 stepping 2 for (i in `{range 0 10 2}) echo $i # echo 0 up to but not including 10 for (i in `{range 10}) echo $i I could whip something up using awk, but someone must already have one! Tom