lazy
produces a lazy evaluation
Usage:
(lazy expr*)
Like delay
, but if the first forced result is a promise, it will continue to be forced until a non-promise result is capable of being returned.
An Example
(define p (lazy
(println "hello once")
(delay
(println "hello twice")
"hello")))
(force p) ;; prints "hello once / hello twice"
(force p)
The first invocation of p
will print “hello once” followed by “hello twice” to the console, also returning the string “hello”. Subsequent invocations of p
will only return “hello”.