Last active
September 4, 2015 04:34
-
-
Save agentcoops/265069 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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)))))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment