Oh, right, so maybe: (last (take-while #(< (apply + %) 100) (reductions conj [] (iterate inc 0)))) => [0 1 2 3 4 5 6 7 8 9 10 11 12 13]
-Steve On 7 Aug 2010, at 13:57, Andreas Liljeqvist wrote: > It should use "+" for reducing the taken list. > Behind the scenes I would envision some accumulator passed to pred. > This examples takes elements while their total sum is less than 100. > > 2010/8/7 Steve Purcell <st...@sanityinc.com> > On 7 Aug 2010, at 11:15, bonega wrote: > > > Hi. > > > > Are there some function like this: > > > > (defn take-while2 [f pred coll] ... > > > > usage: (take-while2 + #(< % 100) (iterate inc 0)) > > returns: (0 1 2 3 4 5 6 7 8 9 10 11 12 13) > > > I'm feeling a bit stupid because I can't see from the above example how > take-while2 is supposed to work. Can you clarify please? > > -Steve > > -- > You received this message because you are subscribed to the Google > Groups "Clojure" group. > To post to this group, send email to clojure@googlegroups.com > Note that posts from new members are moderated - please be patient with your > first post. > To unsubscribe from this group, send email to > clojure+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/clojure?hl=en > > > -- > You received this message because you are subscribed to the Google > Groups "Clojure" group. > To post to this group, send email to clojure@googlegroups.com > Note that posts from new members are moderated - please be patient with your > first post. > To unsubscribe from this group, send email to > clojure+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en