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

[REBOL] Re: Combinations of things (small puzzler)

From: g:santilli:tiscalinet:it at: 21-Oct-2001 12:18

Hello Joel! On 20-Ott-01, you wrote: JN> Sooooooo... Have I missed something in the documentation JN> somewhere? Note that the right number of lines get printed in JN> all cases, it's just that the contents are goofy for JN> recursive invocations of REPEAT with a numeric second JN> argument. It looks like REPEAT does something like: repeat: func ['word value body] [ either series? value [ ... ... bind/copy body word ... ... ] [ ... ... bind body word ... ... ] ] (I think you get the idea...) Indeed, any-n-dices: function [ n [integer!] things [block!] ][ temp len .any-n ][ temp: array n len: length? things do .any-n-dices: func [ p [integer!] n [integer!] b [block!] ][ either p > n [ print b ][ repeat i len copy [ poke b p i .any-n-dices p + 1 n b ] ] ] 1 n temp ] produces:
>> some-things: ["camel" "lemur" "mouse"]
== ["camel" "lemur" "mouse"]
>> any-n-dices 3 some-things
1 1 1 1 1 2 1 1 3 1 2 1 1 2 2 1 2 3 1 3 1 1 3 2 1 3 3 2 1 1 2 1 2 2 1 3 2 2 1 2 2 2 2 2 3 2 3 1 2 3 2 2 3 3 3 1 1 3 1 2 3 1 3 3 2 1 3 2 2 3 2 3 3 3 1 3 3 2 3 3 3 Sounds like something to report to feedback! Regards, Gabriele. -- Gabriele Santilli <[giesse--writeme--com]> - Amigan - REBOL programmer Amiga Group Italia sez. L'Aquila -- http://www.amyresource.it/AGI/