2
我已經與項目創建Leiningen和下面的代碼Core.clj文件中的所有功能:Clojure的REPL無法解析符號
(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")))
等功能
我進入REPL與clojure- jack-in,並用(ns hyperstring.core)切換到我的名字空間。接下來,我試圖啓動任何功能文件,並得到REPL asnswer:
java.lang.Exception: Unable to resolve symbol: read-line-by-line in this context
我怎麼錯過?也許有些選項或代價?
的Clojure-1.4.0,Leiningen-2.0,自吹-1.4.4
是的,這解決了我的問題。謝謝。 – Sigrlami 2012-07-16 18:14:56
要切換到加載的名稱空間,請使用'in-ns',而不是'ns'。 – kotarak 2012-07-17 05:31:40