Next: , Previous: , Up: amb api   [Index]


1.4.1.2 Random selection of choices

The following bindings are exported by the library (vicare language-extensions amb).

Syntax: amb-permute ?expr ...

Like amb but permute the order of the given expressions. The permutation determining the selection order is generated at every first execution of the expanded code, using the random fixnum generator referenced by amb-random-fixnum-maker.

If we define the following function:

(define (choose)
  (amb 1 2 3))

a new permutation is generated at every function invocation.

Syntax: amb-permute ?expr ...

Like amb but randomly select an expression to evaluate; the same expression can be selected multiple times. This syntax never finishes choices. The next expression to evaluate is selected using the random fixnum generator referenced by amb-random-fixnum-maker.

Parameter: amb-random-fixnum-maker

Hold a procedure accepting a fixnum as single argument: when applied to the fixnum N it must return a fixnum in the range [0, N). It is initialised with random from the library (vicare), (vicare-scheme)random.