[英]Clojure: laziness + core.logic: infinite loop
The following code infinite loops: 以下代码无限循环:
(defn ex13 []
(take 5
(run* [x]
(listo (lcons `a (lcons `b (lcons `c x)))))))
Is this supposed to be the right behavior? 这应该是正确的行为吗? (infinite looping?) On the other hand, code like:
(无限循环?)另一方面,代码如:
(take 5 (range))
takes 5 elements and prints them out. 需要5个元素并打印出来。
This may be a bug, however that's not the right way to do it as the results of run* are not truly lazy anyhow. 这可能是一个错误,但是这不是正确的方法,因为run *的结果无论如何都不是真正的懒惰。
(run 5 [x]
(listo (lcons `a (lcons `b (lcons `c x)))))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.