Amb amb Evaluator - SICP Comparison Edition"/>4.3.3   Implementing the <span style="color:green">Amb</span> <span style="color:blue">amb</span> Evaluator - SICP Comparison Edition SICP — Scheme/JS Structure and Interpretation of Computer Programs — Comparison Edition
Original Python
Original Python
Original Python

[1] We chose to implement the lazy evaluator in section 4.2 as a modification of the ordinary metacircular evaluator of section 4.1.1. In contrast, we will base the amb evaluator on the analyzing evaluator of section 4.1.7, because the execution procedures functions in that evaluator provide a convenient framework for implementing backtracking.
[2] We assume that the evaluator supports let (see exercise 4.17), which we have used in our nondeterministic programs.
[3] With this treatment, amb is no longer a name with proper scoping. To avoid confusion, we must refrain from using amb as a name in our nondeterministic programs.
[4] We didn't worry about undoing definitions, since we can assume that internal definitions are scanned out (section 4.1.6). didn't worry about undoing function definitions, since the function object that a definition assigns does not depend on any choice. Likewise, an assignment that creates a new binding in the global environment is not undone, because there is no old value to restore.
4.3.3   Implementing the Amb amb Evaluator