Clojure: laziness + core.logic: infinite loop

Context

The following code of infinite loops:

(defn ex13 [] (take 5 (run* [x] (listo (lcons `a (lcons `b (lcons `cx))))))) 

Question:

Is this supposed to be the right behavior? (infinite loop?) On the other hand, code like:

 (take 5 (range)) 

takes 5 elements and displays them.

+4
source share
1 answer

This may be a mistake, however, this is not the right way to do this, since the run * results are not really lazy.

 (run 5 [x] (listo (lcons `a (lcons `b (lcons `cx))))) 
0
source

Source: https://habr.com/ru/post/1415484/


All Articles