Skip to content

Instantly share code, notes, and snippets.

@klgraham
Created September 9, 2016 08:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save klgraham/2f04d56ed41f86ce58f60178757ad855 to your computer and use it in GitHub Desktop.
Save klgraham/2f04d56ed41f86ce58f60178757ad855 to your computer and use it in GitHub Desktop.
Implementation of a tail-recursive zip list function in Clojure.
(defn zipIndex [coll]
(loop [list coll
n 0
result []]
(if (empty? list)
result
(recur (rest list) (inc n) (conj result [n (first list)])))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment