Hi Ben, That's pretty nifty indeed! Maybe a tad memory intensive as it retains the head, but if it were a more complex, CPU intensive calculation in :next, that might be very worthwhile. Good stuff.
Cheers, -Arnout P.S. The memory consumption will be a little less when I think of a way to efficiently replace the backing LinkedHashMap with an actual persistent map, while keeping track of the evaluation order. Op donderdag 9 oktober 2014 02:53:38 UTC+2 schreef Ben: > > This is pretty nifty: > > user=> (require '[rmap.core :as rmap]) > nil > user=> (def fibs (rmap/rmap FIBS {:a 0 :b 1 :next (-> FIBS (update-in [:a] > (constantly (:b FIBS))) (update-in [:b] (constantly (+ (:b FIBS) (:a > FIBS)))))})) > #'user/fibs > user=> (defn fib [n] (loop [fibs fibs n n] (if (zero? n) (:a fibs) (recur > (:next fibs) (dec n))))) > #'user/fib > user=> (fib 40) > 102334155 > > -- 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 unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.