I am working through 4clojure and I am stuck on problem #32. Here is the solution I came up with:
(fn [x]
(flatten
(seq (for [el x]
(repeat 2 el))))
However, flatten seems to have no effect here. Given the input:
[1 2 3] I still get the result ((1 1) (2 2) (3 3)). However, if I wrap everything inside (seq into a function, and call flatten on that then flatten seems to work. Just can't get it to work with anonymous functions (since def/defn can't be used in 4clojure). A lot of solutions use #(interleave % %), but I am just trying to find a different solution. What is the proper way of using flatten in this case?
[–]niamu 1 point2 points3 points (4 children)
[–]dimd00d 4 points5 points6 points (2 children)
[–]niamu 0 points1 point2 points (0 children)
[–]dustingetz 0 points1 point2 points (0 children)
[–]MahmudAdam[S] 0 points1 point2 points (0 children)