Last Updated: February 25, 2016
·
364
· konr

Instead of nesting maps, use (partial) to manipulate objects deep inside sequences

It's a longer solution, but with less parentheses, more linear, and simpler once you get your head around it.

(->> [[["foo" "bar"] ["bak" "wak"]][["koo" "kar"]]] 
 (map (fn [x] (map (fn [y] (map #(str "X-" %) y)) x))))

versus

(->> [[["foo" "bar"] ["bak" "wak"]][["koo" "kar"]]] 
 ((->> (partial str "X-") (partial map) (partial map) (partial map))))

both yielding

((("X-foo" "X-bar") ("X-bak" "X-wak")) (("X-koo" "X-kar")))