Hi

On 20 March 2011 17:47, Christian <soulbea...@gmail.com> wrote:
> 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)))

Or using Daniel's suggestion:

(reduce + (filter even? (take-while #(< % 4000000) fib-seq)))

> 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.

Yes, that's correct.  IFn means something that implements the "Fn"
interface, i.e. it acts like a function.  There are things in Clojure
which are not really functions, but can be used like functions.

e.g.: ({:foo "bar"} :foo)
or: (:foo {:foo "bar"})

-- 
Michael Wood <esiot...@gmail.com>

-- 
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

Reply via email to