Hi.

I am using max-key to get the longest sequence from a couple of sequences.

(defn cseq [n]
  (if (= 1 n)
    [1]
    (cons n (cseq (if (even? n)
            (/ n 2)
            (+ (* 3 n) 1 ))))))

(apply max-key count (map cseq (range 1 1000000)))

This gives me a heap error.

To my understanding max-key should keep at most two sequences in memory.
I could certainly solve this by working around the problem, but I want to
understand where my logic fails.
Thankful for any help.

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