- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我正在尝试实现 Land of Lisp's Dice of Doom game我得到一个 Don't know how to create ISeq from: clojure.lang.PersistentList$1
。
调用我的 add-new-dice
函数时发生:
(defn add-new-dice [board player spare-dice]
(letfn [(f [lst n]
(cond (empty? lst) nil
(zero? n) lst
:else (let [current-player (first (first lst))
current-dice (first (rest (first lst)))]
(if (and (= current-player player) (< current-dice *max-dice*))
(cons (list current-player (+ current-dice 1))
(f (rest lst) (- n 1)))
(cons (first lst) (f (rest list) n))))))]
(f board spare-dice)))
用这个:
(add-new-dice '[(0 1) (1 3) (0 2) (1 1)] 0 2)
我这样做主要是为了让自己熟悉 CL 代码,并获得一些将其移植到 Clojure 的经验。
如果有人能给我一些建议,我将不胜感激。
最佳答案
您在倒数第二行使用函数 list
而不是参数 lst
。 (f (rest list) n)
应该是 (f (rest lst) n)
关于exception - 不知道如何从 : clojure. lang.PersistentList$1 创建 ISeq,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8742541/
我的模型包含以下枚举和实体: The languages that the person speaks LoadPersonT
如果我加载一个具有多个 PersistentList 属性的对象 - 列表会自动完整加载吗?还是 ZODB 会等到我访问列表的某个元素时才加载它?如果是后者,它是在访问元素时加载整个列表,还是只加载列
亲爱的大家,我对使用 @ElementCollection 注释的 ArrayList 有问题。 我需要它是一个ArrayList,当Hibernate 从 session 中加载对象时,它是一个hi
我正在尝试实现 Land of Lisp's Dice of Doom game我得到一个 Don't know how to create ISeq from: clojure.lang.Persi
我有一些处理列表的函数。我有一个偶数函数,它接受一个列表参数并获取列表的偶数索引。奇函数做同样的事情,但使用奇数索引。我还有另一个函数,它合并两个排序列表,称为 merge-list,它将两个列表作为
我在 Clojure 1.2.1 中看到了这种行为: user=> (type '(1 2)) clojure.lang.PersistentList user=> (type `(1 2)) ;;
我是一名优秀的程序员,十分优秀!