Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sql-server/21.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
Math 为什么我不能用Clojure代码访问我的Leiningen依赖项?_Math_Clojure_Read Eval Print Loop_Leiningen - Fatal编程技术网

Math 为什么我不能用Clojure代码访问我的Leiningen依赖项?

Math 为什么我不能用Clojure代码访问我的Leiningen依赖项?,math,clojure,read-eval-print-loop,leiningen,Math,Clojure,Read Eval Print Loop,Leiningen,在Clojure中,如果我想引入Clojure.inspector函数,我可以这样做: (use `[clojure.math.numeric-tower :include (expt)]) 从REPL,我现在可以计算函数expt 然而,在我看来,应该(也可能是)有另一种方法来实现这一点——使用Leiningen依赖项引入代码 我将此行添加到我的project.clj: [org.clojure/math.numeric-tower "0.0.2"] 然后我重新启动REPL以拉入新的依赖项。

在Clojure中,如果我想引入Clojure.inspector函数,我可以这样做:

(use `[clojure.math.numeric-tower :include (expt)])
从REPL,我现在可以计算函数expt

然而,在我看来,应该(也可能是)有另一种方法来实现这一点——使用Leiningen依赖项引入代码

我将此行添加到我的project.clj:

[org.clojure/math.numeric-tower "0.0.2"]
然后我重新启动REPL以拉入新的依赖项。为了安全起见,我甚至做了“leindeps”(该命令没有输出)。当我尝试计算expt时,它会给我一个RuntimeException,并说它无法解析符号


仅使用Leiningen依赖项如何访问expt函数?

您不能。它不是那样工作的。添加依赖项会将代码放在类路径上,这仅仅意味着它可供您使用。为了实际使用名称空间中的内容,您需要使用

(require '[the-namespace :refer [the things you want to use]])

或者在ns声明中执行上述任一操作(当不在REPL中并使用文件时)

(require '[the-namespace :as tn])
(tn/somevar)
(ns foo
  (:require [the-namespace :as tn]))