1

我正在尝试遵循 Clojure Data Analasys Cookbook 中的示例。我正在使用 LightTable 来玩这个程序。第一个示例显示了如何读入 .csv 数据。

我使用了 lein new getting-data。然后我将这两个依赖项添加到项目文件中

  (defproject getting-data "0.1.0-SNAPSHOT"

  :description "FIXME: write description"
  :url "http://example.com/FIXME"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :dependencies [
                  [org.clojure/clojure "1.5.1"]
                  [incanter/incanter-core "1.4.1"]
                  [incanter/incanter-io "1.4.1"]
                ]
  )

然后在 core.clj 文件中我说如下,在 LightTable 中使用 cmd-shift-enter 来评估程序,但我得到了这些异常:

(use 'incanter.core 'incanter.io)

clojure.lang.Compiler$CompilerException:java.lang.RuntimeException:无法解析符号:在此上下文中使用,正在编译:(/Users/idf/Documents/clojure/getting-data/src/getting_data/core.clj:1: 1)

(read-dataset "data/small-sample.csv") 

clojure.lang.Compiler$CompilerException: java.lang.RuntimeException: Unable to resolve symbol: read-dataset in this context, 编译:(/Users/idf/Documents/clojure/getting-data/src/getting_data/core.clj: 4:1)

不知道我做错了什么?

4

2 回答 2

2

"Unable to resolve symbol: use in this context" means that the light table environment is unable to evaluate basically anything: nothing incanter-related can be the problem. Not using light table, I can't offer further advice on fixing it, but it looks like you've somehow wandered into a namespace that doesn't have clojure.core referred. It should work if you (clojure.core/refer 'clojure.core) before the rest of the code you actually want to run, but of course that's not supposed to be necessary.

于 2014-02-01T07:56:22.743 回答
0

把你的代码

(ns getting-data.core)
(use 'incanter.core 'incanter.io)
(read-dataset "data/small-sample.csv") 

在生成的 core.clj 文件中移到那里并按 strg-enter。现在它应该评估编辑器中的所有内容。或者打开项目并打开一个 Instarepl,LightTable 应该会询问您 repl 应该挂接到哪个项目。

问候弗里克

于 2014-02-20T20:59:52.927 回答