Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

Making series

 [1/2] from: peter::carlsson::space::se at: 19-Oct-2001 8:05


Hello! In Haskell there is a very easy way to create lists. A few examples: [1..5] would create a list [1,2,3,4,5] [1,3..10] would create a list [1,3,5,7,9] [5..0] would create a list [5,4,3,2,1,0] [2..] would create a list [2,3,4,5.. to infinity. Is there a simple way in REBOL to do the same? Best regards, Peter Carlsson ---------------------------------------------------------------- Peter Carlsson Tel: +46 31 735 45 26 Saab Ericsson Space AB Fax: +46 31 735 40 00 S-405 15 Göteborg Email: [peter--carlsson--space--se] SWEDEN URL: http://www.space.se

 [2/2] from: al:bri:xtra at: 20-Oct-2001 8:33


> In Haskell there is a very easy way to create lists.
As too in Rebol:
>> iota 1 5
== [1 2 3 4 5] Of course, you'll need this, first:
>> source iota
iota: func [ {Makes a block containing a range of values, from Start to End.} [catch throw] Start [number! series! money! time! date! char!] "Starting value." End [number! series! money! time! date! char!] "Ending value." /By Bump [number! money! time! char!] "Amount to skip each time." /local Block][ throw-on-error [ all [ none? Bump Bump: 1 ] Block: make block! End - Start / Bump for I Start End Bump [ insert tail Block I ] Block ] ] And you can do neat things like:
>> iota now now + 3
== [20-Oct-2001/8:32:42+13:00 21-Oct-2001/8:32:42+13:00 22-Oct-2001/8:32:42+13:00 23-Oct-2001/8:32:42+13:00] :-) I hope that helps! Andrew Martin ICQ: 26227169 http://valley.150m.com/