paul what version did you use? your version was the first one I tried,
and on 1.2 at least it does not work.

Jules version works, except lambda should be fn in clojure.

On Jul 22, 4:51 pm, Paul  Mooser <taron...@gmail.com> wrote:
> Why not simply do:
>
> (defn fib [n]
>   (println "called with " n)
>   (if (> n 2)
>     (+ (fib (- n 2)) (fib (- n 1)))
>     1))
>
> (def fib (memoize fib))
>
> I inserted the println to verify when we were actually calling the
> function, and I believe this works - fib only seems to get invoked a
> single time for any given n. Is this solution incorrect in some way?

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