JanetDocsPlaygroundI'm feeling luckyGitHub sign in

generate



    macro
    boot.janet on line 623, column 1

    (generate head & body)

    Create a generator expression using the `loop` syntax. Returns a 
    fiber that yields all values inside the loop in order. See `loop` 
    for details.


1 exampleSign in to add an example
Loading...
(def f (generate [i :range [0 5]] (+ i i)))

(print (fiber/status f))
(print (resume f)) 
(print (resume f)) 
(print (resume f)) 
(print (resume f)) 
(print (resume f)) 
(print (fiber/status f)) # -> :pending
(print (resume f)) 
(print (fiber/status f)) # -> :dead


# :new
# 0
# 2
# 4
# 6
# 8
# :pending
#
# :dead
leobmPlayground