I'm trying to use ClojureScript instead Clojure lately.
When I compile and run on node.js
(.log js/console (range 10))
I've got
$ node app
{ meta: null,
start: 0,
end: 10,
step: 1,
__hash: null,
'cljs$lang$protocol_mask$partition1$': 0,
'cljs$lang$protocol_mask$partition0$': 32375006 }
I'm a bit surprised to see this simple code does not work.
Is this due to my specific environment? I hope so, and if it's a problem of my side, please advise.
Here is the compiled js:
cljs.nodejs = {};
cljs.nodejs.require = require;
cljs.nodejs.process = process;
cljs.core.string_print = cljs.nodejs.require.call(null, "util").print;
var rxcljs = {core:{}};
console.log(cljs.core.range.call(null, 10));
You can either console.log the string representation of (range 10):
(.log js/console (pr-str (range 10)))
or simply use the println function:
(println (range 10))
In either case, (0 1 2 3 4 5 6 7 8 9) is printed as expected.
Looks like you want to print the vector instead; range returns a lazy seq.
Try this:
(.log js/console (vec (range 10)))