Created
September 9, 2016 08:50
-
-
Save klgraham/2f04d56ed41f86ce58f60178757ad855 to your computer and use it in GitHub Desktop.
Implementation of a tail-recursive zip list function in Clojure.
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 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