Skip to content

Instantly share code, notes, and snippets.

Created July 26, 2015 07:21
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/b840211c8ce0088d79da to your computer and use it in GitHub Desktop.
Save anonymous/b840211c8ce0088d79da to your computer and use it in GitHub Desktop.
I have this data:
[[[1 1] 300000] [[2 2] 150000] [[3 3] 120000] [[4 4] 100000] [[5 5] 80000] [[6 6] 70000] [[7 9] 60000]]
When going through each element, I want to do this:
In [[1 1] 30000], I want to output a vector of [1 30000] because [1 1] is a range that corresponds to 1
In [[7 9] 60000], I want to output vectors of [7 60000], [8 60000], and [9 60000]
I should wind up with:
[[1 300000] [2 150000] [3 120000] [4 100000] [5 80000] [6 70000] [7 60000] [8 60000] [9 60000]]
I tried this function:
(fn [item]
(let [[[x y] z] item]
(map #(vec [% z])
(range x (+ y 1)))))
But it's confusing, and yielded this
(([1 300000]) ([2 150000]) ([3 120000]) ([4 100000]) ([5 80000]) ([6 70000]) ([7 60000] [8 60000] [9 60000]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment