Skip to content

Instantly share code, notes, and snippets.

@fogus
Forked from agentcoops/gist:265069
Created December 29, 2009 02:32
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fogus/265107 to your computer and use it in GitHub Desktop.
Save fogus/265107 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