Atlassian uses cookies to improve your browsing experience, perform analytics and research, and conduct advertising. Accept all cookies to indicate that you agree to our use of cookies on your device. Atlassian cookies and tracking notice, (opens new window)
filter on lazy seq causes stack overflow
Description
This expression causes a stack overflow, instead evaluating to 9999:
(first (filter #(= 9999 %) (range)))
These expressions should be equivalent, and do not cause a stack overflow:
This expression causes a stack overflow, instead evaluating to 9999:
(first (filter #(= 9999 %) (range)))
These expressions should be equivalent, and do not cause a stack overflow:
(first (filter #(= 9999 %) (vec (take 10000 (range)))))
(some #(when (= 9999 %) %) (range))
Thus, it seems as if filter cannot handle an input that's already lazy.
More elaborate version: https://www.refheap.com/18490
See also this google group thread: https://groups.google.com/forum/#!topic/clojurescript/3NlQOxwNrRc
Please consider using ssl on dev.clojure.org ##