>>>>> "Adam" == Adam  <[email protected]> writes:

Adam> Is there a feature in Factor that acts like Generators in
Adam> Python?  I.E. adding an iteration protocol where a result is
Adam> computed, returned, and then yeilds to the caller?

You can also use lazy lists (in "lists.lazy"). For an example, you can
look at "math.primes.lists", where "lprimes" is an infinite stream
containing all the prime numbers:

  USE: math.primes.lists
  100000 lprimes lnth
  ===> 1299721

"lprimes" is defined as its first element and a word to get from the
current element to the next one:

  : lprimes ( -- list ) 2 [ next-prime ] lfrom-by ;

 Sam
-- 
Samuel Tardieu -- [email protected] -- http://www.rfc1149.net/


------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
Factor-talk mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/factor-talk

Reply via email to