Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/clojure/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/extjs/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Clojurescript clojure.set不工作_Clojure_Clojurescript - Fatal编程技术网

Clojurescript clojure.set不工作

Clojurescript clojure.set不工作,clojure,clojurescript,Clojure,Clojurescript,我已经引用了文档字符串,但实际上运行任何clojure.set函数都不起作用。在Opera 28.0上使用ClojureScript 0.0-3126和/或在Windows 7 x64上使用Chrome 41.0.2272.101 m 关于如何纠正这个问题有什么想法吗? 谢谢 ClojureScript:cljs.user>(需要“[clojure.set]”) 无 ClojureScript:cljs.user>(doc clojure.set/union) -----------------

我已经引用了文档字符串,但实际上运行任何
clojure.set
函数都不起作用。在Opera 28.0上使用ClojureScript 0.0-3126和/或在Windows 7 x64上使用Chrome 41.0.2272.101 m

关于如何纠正这个问题有什么想法吗? 谢谢

ClojureScript:cljs.user>(需要“[clojure.set]”)
无
ClojureScript:cljs.user>(doc clojure.set/union)
-------------------------
clojure.set/union
([[s1][s1 s2][s1 s2和集合])
返回一个集,该集是输入集的并集
无
ClojureScript:cljs.user>(clojure.set/union{:a}{:b})
TypeError:无法读取未定义的属性“union”
TypeError:无法读取未定义的属性“union”
在评估时(评估时)(http://localhost:8888/js/coreweb.js:45250:260), :1:100)
在评估时(评估时)(http://localhost:8888/js/coreweb.js:45250:260), :9:3)
评估时(ev al评估时)(http://localhost:8888/js/coreweb.js:45250:260), :14:4)
在http://localhost:8888/js/coreweb.js:45250:255
在clojure$browser$repl$evaluate\u javascript(http://localhost:8888/js/coreweb.js:45256:4)
在Object.callback(http://localhost:8888/js/coreweb.js:45421:181)
在goog.messaging.AbstractChannel.deliver(http://localhost:8888/js/coreweb.js:42499:13)
在goog.net.xpc.CrossPageChannel.xpcDeliver上(http://localhost:8888/js/coreweb.js:43463:14)
在Function.goog.net.xpc.NativeMessagingTransport.messageReceived\u(http://localhost:8888/js/coreweb.js:42859:13)
在Object.goog.events.fireListener(http://localhost:8888/js/coreweb.js:39835:21)

这与其说是答案,不如说是个人研究。尽管如此,我还是用Chrome(在MAC上)复制了你的问题,并使用了ClojureScript

如果cljs服务器repl文件如下所示(即
clojure.set上没有
require
):

repl.clj
是:

(require 'cljs.repl)
(require 'cljs.closure)
(require 'cljs.repl.browser)

(cljs.closure/build "src"
                    {:main 'hello-world.core
                     :output-to "out/main.js"
                     :verbose true})

(cljs.repl/repl (cljs.repl.browser/repl-env)
                :watch "src"
                :output-dir "out")
然后在终端中使用以下命令启动repl:

rlwrap java -cp cljs.jar:src clojure.main repl.clj
并在
http://localhost:9000
,则此操作有效:

ClojureScript:cljs.user> (require '[clojure.set])
nil
ClojureScript:cljs.user> (clojure.set/union #{6} #{9} #{7})
#{7 6 9}
现在,如果重新加载服务器页面
http://localhost:9000
,然后再试一次,我遇到了问题(符号上有doc,但var不再存在):


然后,看起来您仍然需要从repl中获取clojure.set才能使用其功能,但是,您可以重新加载服务器页面,并且它仍然在repl中工作。

这是一个奇怪的错误。在遵循获取工作REPL的说明之后,我在评估您发布的代码时没有发现任何错误。假设我没有尝试您提到的特定ClojureScript版本,我只是下载了该指南中链接的jar,因此它可能是
0.0-3126
版本中的一个bug。
rlwrap java -cp cljs.jar:src clojure.main repl.clj
ClojureScript:cljs.user> (require '[clojure.set])
nil
ClojureScript:cljs.user> (clojure.set/union #{6} #{9} #{7})
#{7 6 9}
ClojureScript:cljs.user> (doc clojure.set/union)
-------------------------
clojure.set/union
([] [s1] [s1 s2] [s1 s2 & sets])
  Return a set that is the union of the input sets
nil
ClojureScript:cljs.user> (clojure.set/union #{6} #{9} #{7})
TypeError: Cannot read property 'union' of undefined
TypeError: Cannot read property 'union' of undefined
    at eval (eval at <anonymous> (http://localhost:9000/out/clojure/browser/repl.js:42:272), <anonymous>:1:100)
(ns hello-world.core
      (:require [clojure.browser.repl :as repl]
                [clojure.set]))