Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Clojure linked list using defrecord
(defrecord ListNode [value next])
(defn add-node [^ListNode curr v]
(if curr
(assoc curr :next (add-node (:next curr) v))
(ListNode. v nil)))
(def result
(loop [l nil i 0]
(if (< i 100000)
(recur (add-node l i) (inc i))

This comment has been minimized.

Copy link
Owner Author

@upgradingdave upgradingdave commented Aug 2, 2018

How can I optimize add-node so it doesn't stackoverflow?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment