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
Clojure 为什么大猩猩会抛出“无法解析符号”错误?_Clojure_Require - Fatal编程技术网

Clojure 为什么大猩猩会抛出“无法解析符号”错误?

Clojure 为什么大猩猩会抛出“无法解析符号”错误?,clojure,require,Clojure,Require,:require在中似乎不起作用。我打开一个新会话并运行以下操作: (ns pacific-iceberg (:require [gorilla-plot.core :as plot])) (defn f [x] (Math/pow x 2)) (plot f [-9 9]) 输出: An exception was caused by: java.lang.RuntimeException (Unable to resolve symbol: plot in this context)

:require
在中似乎不起作用。我打开一个新会话并运行以下操作:

(ns pacific-iceberg
  (:require [gorilla-plot.core :as plot]))

(defn f [x] (Math/pow x 2))
(plot f [-9 9])
输出:

An exception was caused by: java.lang.RuntimeException (Unable to resolve symbol: plot in this context)
...

发生了什么事?

你把
:as
:refere
弄糊涂了。Clojure的
require
解释:

公认的选择:

:as将符号作为其参数,并将该符号作为 当前命名空间中的lib命名空间

:refere从名称空间或:all中获取要引用的符号列表 关键字以引入所有公共变量


如果你想要一个名为“plot”的函数,并且你想引用它而不使用名称间隔,请使用
:refereplot
,但是如果你想使名称空间显式(我的偏好),那么就使用类似
:as gorilla
的东西,然后用
gorilla/plot
来调用它,对吧。我应该使用
(plot/plot f[-9])
。谢谢!工作起来很有魅力!