Jafar Al-Gharaibeh wrote: > 1- every writes( ! name) will print out "Jose Jimenez" > but, > 2- writes( ! name) will print out only the first letter "J" > > the ! is a generator. Generators doesn't produce more values if they succeed > and the surrounding expression doesn't "ask" then for more. In case 2 > above. ! name produces J in the first time. writes take the J and prinst it > out, succeeds and then go home happy. Done ! :-) > > in case 1 however, after the scenario above, "every" that is surrounding > (!name) always fail to force the generator to produce all of the possible > values.. > > -jafar > > > > On Thu, Oct 22, 2009 at 8:46 PM, Sidney Reilley II < > [email protected]> wrote: > >> Hey... >> >> Given: >> name := "Jose Jimenez" >> every writes( ! name) >> >> The ! operator generates each letter of the string literal. >> So it dishes out one letter at a time to "write". >> "write" prints it. >> >> I don't see where "every" fits in? I realize that I'm not translating >> the code properly. >> -- >> Sid
Thank you for the reply! Allow me to paraphrase and summarize, to see if I understand the logic: The ! operator is a generator that indeed is able to iterate through a "string literal, list. etc, one element at a time. By default, ! is /not/ "greedy" - it will stop after the first success. Use "every" to force the ! operator to return all possible values - i.e. backtracking - in this case - must be forced. How close did I get? -- 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
