简单的clojure程序不起作用

时间:2014-01-31 20:45:34

标签: clojure lighttable

我正在尝试按照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:无法在此上下文中解析符号:read-dataset,编译:(/ Users / idf / Documents / clojure / getting-data / src / getting_data / core .clj:4:1)

不确定我做错了什么?

2 个答案:

答案 0 :(得分:2)

“无法解析符号:在此上下文中使用”意味着光表环境基本上无法评估任何内容:没有任何与此相关的问题可能是问题所在。不使用light table,我无法提供有关修复它的进一步建议,但看起来你已经以某种方式徘徊在没有引用clojure.core的命名空间中。如果您在实际想要运行的其余代码之前(clojure.core/refer 'clojure.core),它应该可以工作,但当然这不是必需的。

答案 1 :(得分:0)

把你的代码

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

在生成的core.clj文件中移动并按strg-enter。现在它应该评估编辑器中的所有内容。或者打开项目并打开一个Instarepl,LightTable应该询问你应该进入哪个项目。

问候 FRICKE

相关问题