【发布时间】:2015-01-11 07:06:21
【问题描述】:
如果我从这样的函数返回一个惰性序列:
(letfn [(permutations [s]
(lazy-seq
(if (seq (rest s))
(apply concat (for [x s]
(map #(cons x %) (permutations (remove #{x} s)))))
[s])))])
如果我像下面这样使用循环重复,列表会被急切地评估吗?
(loop [perms (permutations chain)]
(if (empty? perms)
(prn "finised")
(recur (rest perms))))
如果急切地评估它,我可以使用 loop..recur 懒惰地循环从 permutations 函数返回的内容吗?
【问题讨论】: