Barry Schwartz wrote:
> Sidney Reilley II <[email protected]> skribis:
>> The following snippet is taken from Thomas W. Christopher's book,
>> "Icon Programming Language Handbook", page 36
>>
>> [quote]
>> The to operator associates to the left, e.g.,
>>
>> every writes(" ",1 to 2 to 3)
>> [/quote]
>>
>> I don't understand how the following produces:
>>
>> 12323
>>
>> I'm reading the above code as:
>>
>> write "each" integer 1 and 2 then "each" integer 2 and 3
>>
>> So I'm thinking the result should be:
>>
>> 1223
>>
>> but obviously I'm wrong, and I'm missing a piece of the puzzle.
>
> every writes(" ",(1 to 2) to 3)
>
> First tries (1 to 3) then tries (2 to 3), before failing, giving "1 2
> 3" followed by "2 3".
I got it! The generator (1 to 2) first returns 1, which becomes the
L.H.S of the "to 3" generator. After all the values are generated - 1
2 3 - "backtracking" occurs to get the next L.H.S. value, which in
turn is applied to the "to 3" generator. The values 2 3 are generated.
No more values? - Failure!!
Am I getting it?
> every writes(" ", 1 to (2 to 3))
>
> would try (1 to 2) and then (1 to 3), giving "1 2" followed by "1 2 3".
Same rationalization as above.
Thanks for explanation.
--
Sid
------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Unicon-group mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/unicon-group