我似乎对 clojure I/O(或类型系统)有严重的问题。关键是这个函数,我希望使用字符串和数字或字符串的集合,并返回与数字相关的字符串字典,比如
(costlist '( '("Milk" 4) '("Bread" 2) '("Milk")))
给予
{"Milk" 4, "Bread" 2 }
被定义为
(defn costlist [lst]
;returns list of costs and appropriate names
(let [snds (filter (fn [x] (not (identical? nil x))) (seconds lst))]
(zipmap
(firsts (take (count snds) (firsts lst)))
(snds lst))))
当使用 clojure.lang.PersistentList 类型的列表(我从 clojure.lang.LazySeq 转换而来)时抛出错误消息
clojure.lang.LazySeq cannot be cast to clojure.lang.IFn
这只会让我感到困惑,因为它的任何论点对我来说似乎都不是 LazySeq。