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
Debugging 为什么可以';t lein repl find函数?_Debugging_Clojure_Leiningen - Fatal编程技术网

Debugging 为什么可以';t lein repl find函数?

Debugging 为什么可以';t lein repl find函数?,debugging,clojure,leiningen,Debugging,Clojure,Leiningen,我正在使用 [ics@steamboy util]$ lein version Leiningen 2.5.1 on Java 1.7.0_91 OpenJDK Server VM 使用Clojure 1.6 在leinrepl中,我曾经能够从repl中调用函数 util.core=> (load-file "src/util/core.clj") #'util.core/-main util.core=> (bldg-sqft-test) (defn ret-val-from-

我正在使用

[ics@steamboy util]$ lein version
Leiningen 2.5.1 on Java 1.7.0_91 OpenJDK Server VM
使用Clojure 1.6

leinrepl
中,我曾经能够从
repl
中调用函数

util.core=> (load-file "src/util/core.clj")
#'util.core/-main
util.core=> (bldg-sqft-test)
(defn ret-val-from-sos
  "Takes a value, a map key, an s-o-s, and returns first match."
  [in-val map-key-1 map-key-2 s-o-s]
  (doseq [x s-o-s]
    (println (str (first x)))))

(defn bldg-sqft-test
  [& args]
  (let [bldg-cols (fetch-csv-data "bldg_sqft_cols.csv")
        bldg-data (fetch-csv-data "Buildingsqft.csv")
        mapped-data (xform-sos-in bldg-data bldg-cols)
        my-bldg-sqft (ret-val-from-sos (str 70782) (keyword "Bill#") (keyword "Fin. Area") mapped-data)]
    my-bldg-sqft))
并从
repl
中执行一个函数

util.core=> (load-file "src/util/core.clj")
#'util.core/-main
util.core=> (bldg-sqft-test)
(defn ret-val-from-sos
  "Takes a value, a map key, an s-o-s, and returns first match."
  [in-val map-key-1 map-key-2 s-o-s]
  (doseq [x s-o-s]
    (println (str (first x)))))

(defn bldg-sqft-test
  [& args]
  (let [bldg-cols (fetch-csv-data "bldg_sqft_cols.csv")
        bldg-data (fetch-csv-data "Buildingsqft.csv")
        mapped-data (xform-sos-in bldg-data bldg-cols)
        my-bldg-sqft (ret-val-from-sos (str 70782) (keyword "Bill#") (keyword "Fin. Area") mapped-data)]
    my-bldg-sqft))
当我可以检查repl中的变量时,调试就更容易了。作为一种解决方法,我已将库转换为使用main运行,但它不如
repl
调试有效


我需要在repl中执行哪些设置/配置调用函数?

当您运行
$lein repl
时,JVM实例将启动,它将加载类路径中的所有名称空间,因此不需要(加载文件“example.clj”)

您尝试执行的正确顺序是:

$ lein repl
user=>(require 'util.core)
nil
user=>(in-ns 'my-ns.core)
nil
my-ns.core=>(bldg-sqft-test)


如果您需要加载一个外部.clj文件,则
(加载文件“external.clj”)
会将该文件添加到类路径,然后您可以如上所述要求名称空间。

运行函数时会出现类型转换异常。如果不知道涉及的其他代码,就很难确切知道问题出在哪里。此外,您应该能够使用(require'util.core)而不是(load file)在命名空间中加载。您得到的异常本身应该是一个问题,它与repl无关。我不关心这个错误,也不关心为什么找不到该函数。