Skip to content

Instantly share code, notes, and snippets.

@agentcoops
Last active September 4, 2015 04:34
Show Gist options
  • Save agentcoops/265069 to your computer and use it in GitHub Desktop.
Save agentcoops/265069 to your computer and use it in GitHub Desktop.
(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