The amb operator implements a system which is capable of automatically searching for a set of values for variables (henceforth called ambiguous variab

phoe / amb Public

submited by
Style Pass
2022-01-12 22:00:10

The amb operator implements a system which is capable of automatically searching for a set of values for variables (henceforth called ambiguous variables) for which a set of constraints is satisfied. The operator and its example use are described in detail in Structure and Interpretation of Computer Programs Chapter 4.3 (Nondeterministic Computing).

The direct API consists of two macros, amb and constrain, which, respectively, bind ambiguous variables and place constraints which, if not met, cause the code to backtrack and select the next combination of values to try.

If no match is found, a warning amb-failure might be signaled. The amb stack for which no match was found can be retrieved from that condition via the amb-failure-stack reader function.

Screamer offers a much more complete and optimized environment for writing nondeterministic Common Lisp, at a cost of being big in terms of lines of code and complexity, as well as needing to shadow many symbols of standard Common Lisp.

Leave a Comment
Related Posts