Skip to content

Instantly share code, notes, and snippets.

Created April 10, 2010 19:11
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 anonymous/362235 to your computer and use it in GitHub Desktop.
Save anonymous/362235 to your computer and use it in GitHub Desktop.
(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