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

[REBOL] Re: Monday Puzzle

From: jelinem1:nationwide at: 24-Jul-2001 8:22

Here's a "brute force" solution. All else I can think of are either a variation of this, or require more code to set up the 'y block.
>> f: does [a: [9] either 9 = a/1 [a/1: 0][a/1: 1 + a/1]] >> y: []
== []
>> append y :f
== [func [][a: [9] either 9 = a/1 [a/1: 0] [a/1: 1 + a/1]]]
>> append/only y y
== [func [][a: [9] either 9 = a/1 [a/1: 0] [a/1: 1 + a/1]] [...]]
>> ; ---------------------------------------------------- >> loop 20 [prin [y/1 " "] y: second y] print ""
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9
>> loop 20 [prin [length? y " "] y: second y] print ""
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 A nice diversion from work. - Michael Jelinek From: "Larry Palmiter" <[larry--ecotope--com]>@rebol.com on 07/23/2001 10:29 PM Please respond to [rebol-list--rebol--com] Sent by: [rebol-bounce--rebol--com] To: <[rebol-list--rebol--com]> cc: Subject: [REBOL] Monday Puzzle Hi all, Here's a puzzle. I made a block named y of length 2 which shows the following behavior:
>> type? y
== block!
>> length? y
== 2
>> y/1
== 0
>> loop 20 [prin [y/1 " "] y: second y] print ""
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 Here's a hint!
>> loop 20 [prin [length? y " "] y: second y] print ""
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 How was the block constructed and what does the MOLD of the block look like? Enjoy -Larry