我最近尝试使用ClojureScript代替Clojure。
当我在node.js上编译并运行时
(.log js/console (range 10))
我有
$ node app
{ meta: null,
start: 0,
end: 10,
step: 1,
__hash: null,
'cljs$lang$protocol_mask$partition1$': 0,
'cljs$lang$protocol_mask$partition0$': 32375006 }
看到这个简单的代码不起作用,我感到有些惊讶。
这是由于我的特定环境吗?我希望如此,如果这是我这方面的问题,请告知。
这是编译的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));
最佳答案
您可以console.log
(range 10)
的字符串表示形式:
(.log js/console (pr-str (range 10)))
或简单地使用
println
函数:(println (range 10))
在任何一种情况下,
(0 1 2 3 4 5 6 7 8 9)
都会按预期打印。