Created
April 10, 2010 19:11
-
-
Save anonymous/362235 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 map-lr-vecs [f v] | |
(reduce (fn [result index] | |
(conj result | |
(f (subvec v 0 index) | |
(get v index) | |
(subvec v (inc index))))) | |
[] | |
(range (count v)))) | |
(map-lr-vecs (fn [left val right] | |
(println [left val right]) | |
val) | |
[1 2 3 4 5 6]) | |
[[] 1 [2 3 4 5 6]] | |
[[1] 2 [3 4 5 6]] | |
[[1 2] 3 [4 5 6]] | |
[[1 2 3] 4 [5 6]] | |
[[1 2 3 4] 5 [6]] | |
[[1 2 3 4 5] 6 []] | |
[1 2 3 4 5 6] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment