Created
August 24, 2010 16:27
-
-
Save fogus/547833 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
;; returns a map | |
(def numbered-elements (partial zipmap (iterate inc 0))) | |
(numbered-elements '[a b c d]) | |
;=> {3 d, 2 c, 1 b, 0 a} | |
;; returns a seq of pairs | |
(def numbered-elements #(->> % (interleave (iterate inc 0)) (partition 2))) | |
(numbered-elements '[a b c d]) | |
;=> ((0 a) (1 b) (2 c) (3 d)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment