I am a newbie, but seems that "for comprehension" are lazy lists:
user> (take 5 (for [x (range 20) :when (do (printf "*%d* " x) (= (rem x 2) 1))] x)) (*0* *1* *2* *3* 1 *4* *5* 3 *6* *7* 5 *8* *9* 7 9) So, I think that you should use take :) 2009/4/21 Michael Hunger <[email protected]> > > Is it possible to use :while to shortcut a for macro when a certain number > of yiels have happened? > > e.g. (for [x (range 1000) :when (= (rem x) 1) :while (number of yields <= > 10)] > > so i want only the first 10 results. > > Or should I just use (take 10 ) on the for ? > > Michael > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~----------~----~----~----~------~----~------~--~---
