加载 Clojure-contrib
我对整个 JVM 很陌生,正在尝试使用 clojure。我正在尝试加载 clojure-contrib 并失败:
# in bash
$ java -cp /path/to/clojure.jar:/path/to/contrib.jar clojure.main
# in REPL
user=> (require 'clojure.contrib.math)
nil
user=> (sqrt 2)
java.lang.Exception: Unable to resolve symbol: sqrt in this context (NO_SOURCE_FILE:10)
任何指针都会很棒 - 谢谢。
I'm new to the whole JVM thing, and trying to play with clojure. I'm attempting to load clojure-contrib and failing:
# in bash
$ java -cp /path/to/clojure.jar:/path/to/contrib.jar clojure.main
# in REPL
user=> (require 'clojure.contrib.math)
nil
user=> (sqrt 2)
java.lang.Exception: Unable to resolve symbol: sqrt in this context (NO_SOURCE_FILE:10)
Any pointers will be great - thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您应该将 refer 放在 require 之后,这会将所有符号映射到当前命名空间。
有关详细介绍,您可以阅读 wikibooks 文章。
http://en.wikibooks.org/wiki/Clojure_Programming/Concepts#Refer_and_Use
You should put refer after require which will map all the symbols into current namespace
For detailed intro you may read wikibooks article.
http://en.wikibooks.org/wiki/Clojure_Programming/Concepts#Refer_and_Use
我不是专家,但这似乎是一个命名空间问题。我采用的解决方案是这样的:
I'm no expert, but it seemed like a namespace issue. The solution I employed was this: