我用 Leiningen 创建了项目,并在Core.clj文件中添加了以下代码:
(ns hyperstring.core
(:use [clojure.pprint :only (pprint)])
(:require [clojure.java.io :as io]
[clojure.string :as str])
(:import [java.io File]))
;;read file line by line
(defn read-line-by-line [filepath]
(with-open [rdr (reader filepath)]
(doseq [line (line-seq rdr)]
(println line))))
;;write to a new file
(defn write-file [filepath]
(with-open [wrtr (writer filepath)]
(.write wrtr "Line to be written")))
和其他功能
我使用clojure-jack-in进入 REPL并使用(ns hyperstring.core)切换到我的命名空间。接下来,我尝试在文件中启动任何函数并获取 REPL 答案:
java.lang.Exception: Unable to resolve symbol: read-line-by-line in this context
我想念什么?也许一些选项或部门?
clojure-1.4.0、Leiningen-2.0、swank-1.4.4