Nested lists
Write a function that nests the elements of a list one level deeper by repeating that element inside a new list a given number of times.
Examples
(nest [:a :b :c] 2) ;=> ((:a :a) (:b :b) (:c :c))
(nest [] 10) ;=> ()
(nest [1 2 3 4] 1) ;=> ((1) (2) (3) (4))
(nest [1 2 3] 0) ;=> (()()())
Thanks to this site for the challenge idea where it is considered Hard in Java.
Please submit your solutions as comments on this gist.
well, trying to bring functional to python too (ignore the imports 😉).
disclaimer: not as beautiful as the clojure version