Created
July 9, 2010 18:05
-
-
Save qbg/469794 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 convert-alist | |
[alist] | |
(let [size (apply max (map first alist))] | |
(reduce (fn [v [i o]] (assoc v (dec i) o)) | |
(vec (repeat size nil)) | |
alist))) |
slyrus
commented
Jul 9, 2010
Ok then, this should do it:
(defn convert-alist
[alist & [key first]]
(reduce (fn [v x] (assoc v (key x) x))
(vec (repeat (apply max (map key alist)) nil))
alist))
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment