public
Last active

  • Download Gist
gistfile1.clj
Clojure
1 2 3 4 5 6 7 8 9
(defn listify [orig-list]
"Turns (1 2 3 ...) into (1 (2 (3 (...)))) using continuation passing style."
(loop [lst orig-list cont identity]
(if (= () lst)
(cont ())
(recur (rest lst)
(fn [insert]
(cont (cons (first lst)
(list insert))))))))

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.