Hello Tassilo! I've tested your code and looked at the Clojure Documentation for 'for'. Given that, I have written
(reduce +(filter even? (for [fib (fib-seq) :while (< fib 4000000)] fib))) This gives me the error 'clojure.lang.LazySeq cannot be cast to clojure.lang.IFn'. I think this is because fib-seq is a var, not a function (although I was hard-pressed finding out what IFn stood for.) When I omit the () with [fib (fib-seq)...], the program works just as expected. I would like to thank you for this suggestion and the way you translated the problem statement into code! Do you have any resources or books that help with such things? (Taking a problem and solving it the way you did) On Mar 20, 11:18 am, Tassilo Horn <tass...@member.fsf.org> wrote: > Christian <soulbea...@gmail.com> writes: > > Hi Christian, > > > For those unfamiliar, Project Euler Problem 2 states: > > find the sum of all > > Sounds like (reduce + ...). > > > even-valued fibonacci terms > > Sounds like (filter even? ...) > > > that are less than four million. > > Hm, that's a bit more challenging. I think, you could go with > > (for [fib (fib-seq) :while (< fib 4000000)] > fib) > > Of course, this is all completely untested. :-) > > Bye, > Tassilo -- 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