Welcome! Please see the About page for a little more info on how this works.

0 votes
in ClojureScript by
edited by

Hi

(map (fn [x] [:div x x]) ["abc" "xyz"])

in Clojure REPL the result is [[:div "abc" "abc"] [:div "xyz" "xyz"]],
but when executed in browser (js), clojurescript returns
a flatten seq: [:div "abc" "abc :div "xyz" "xyz"]

how to handle this in clojrescript?

I am trying
(doseq [x (map (fn [x] [:div x x]) ["abc" "xyz"])]
(js/console.log x))
:div
"abc"
"abc"
:div
"xyz"
"xyz"

I am expecting:
(doseq [x (map (fn [x] [:div x x]) ["abc" "xyz"])]
(js/console.log x))
[:div "abc" "abc"] [:div "xyz" "xyz"]

regards
-Taoufik

1 Answer

0 votes
by

Are you sure that you don't have something like (def map mapcat) somewhere above that doseq and that whatever you use to view the output of js/console.log doesn't expand the [:div ...] vectors for you? Because if your hypothesis about map being broken in CLJS were correct, the whole CLJS would be broken, which is not the case.

...