Next: amb api utilities, Previous: amb api random, Up: amb api [Index]
The following bindings are exported by the library (vicare
language-extensions amb).
Like amb but generate the next choice by evaluating a thunk.
generator-thunk must be a thunk, which, when evaluated, returns
the next choice; when no more choices are available
generator-thunk must evaluate (amb).
#!r6rs
(import (vicare)
(vicare language-extensions amb))
(define-values (empty? enqueue! dequeue!)
(make-queue '(1 2 3 4)))
(define (generator)
(if (empty?)
(amb)
(dequeue!)))
(with-ambiguous-choices
(let ((R (amb-thunk generator)))
(amb-assert (<= 3 R))
R))
⇒ 3