Fairly new to clojure. When I was browsing a solution to one of the
problems in project Euler, I came across a solution that used a
recursive var definition.

;By considering the terms in the Fibonacci sequence whose values do
not
;exceed four million, find the sum of the even-valued terms.
(def fibs
  (lazy-cat '(0 1) (map + fibs (drop 1 fibs))))

(def result
  (reduce +
    (take-while (partial >= 4000000) (filter even? fibs))))

I have never seen a recursive var definition such as fibs above and
fail to understand how it works. When I read the fibs definition
above, it looks like to define fibs it already should know about fibs
since it is used in the map function. How does this work? And is this
a good/idiomatic practice?

Thanks
Shoeb

PS: Message to owner of this google group: Could you remove my other
email address "shua...@gmail.com" from the banned list? Thanks.

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