add docs example for in-generator, where arity > 1
This commit is contained in:
parent
ac21f854a2
commit
d5c2443c05
|
@ -1050,6 +1050,18 @@ values from the generator.
|
||||||
@racket[#:arity arity-k] clause; the @racket[arity-k] must be a
|
@racket[#:arity arity-k] clause; the @racket[arity-k] must be a
|
||||||
literal, exact, non-negative integer.
|
literal, exact, non-negative integer.
|
||||||
|
|
||||||
|
@examples[#:eval generator-eval
|
||||||
|
(let ([g (in-generator
|
||||||
|
(let loop ([n 3])
|
||||||
|
(unless (zero? n) (yield n (add1 n)) (loop (sub1 n)))))])
|
||||||
|
(let-values ([(not-empty? next) (sequence-generate g)])
|
||||||
|
(let loop () (when (not-empty?) (next) (loop))) 'done))
|
||||||
|
(let ([g (in-generator #:arity 2
|
||||||
|
(let loop ([n 3])
|
||||||
|
(unless (zero? n) (yield n (add1 n)) (loop (sub1 n)))))])
|
||||||
|
(let-values ([(not-empty? next) (sequence-generate g)])
|
||||||
|
(let loop () (when (not-empty?) (next) (loop))) 'done))]
|
||||||
|
|
||||||
To use an existing generator as a sequence, use @racket[in-producer]
|
To use an existing generator as a sequence, use @racket[in-producer]
|
||||||
with a stop-value known for the generator:
|
with a stop-value known for the generator:
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user