我是clojure的新手,我正在解决一个问题......
我正在尝试查找文件中所有教师的频率,但我不知道从哪里开始。我之前在一个不同的程序中做过这个并且它有效,但现在我收到的错误是“#34;更新不能在这个上下文中使用"
(defn read-lines [filename]
(with-open [rdr (clojure.java.io/reader filename)]
(doall (line-seq rdr))))
(defn classes [s]
(reduce conj (map hash-map [:semester :title :crn :code :levels :credits
:campus :section :capacity :actual :starthout :startmin
:endhour :endmin :weekday :room :datestart
:dateend :schtypye :instructor :prereq :corereq] (.split s ";"))))
(println(map classes (read-lines "C:/Users/Rohil's Computer/Desktop/textfile.txt")))
(loop [semester->instructor {}
[{:keys [semester instructor] :as row} & rows] classes]
(if (nil? row)
semester->instructor
(recur (update semester->instructor semester (fnil conj []) instructor) rows)))