6 ms·
Is this the same as the amb form, as seen in SICP? https://mitpress.mit.edu/sicp/full-text/book/book-Z-H-28.html#%_sec_4.3.1 https://mitpress.mit.edu/sicp/full
by ridiculous_fish 11y ago
Is this the same as the amb form, as seen in SICP?
https://mitpress.mit.edu/sicp/full-text/book/book-Z-H-28.html#%_sec_4.3.1 https://mitpress.mit.edu/sicp/full-text/book/book-Z-H-28.htm...
- dangirsh 11y agoAmb is implemented with a backtracking evaluator and supports a try-again operation for requesting all valid outputs (universes). This library just forks the process for each "universe" and kills the ones where fail is called (including failing assertions). It can only return the first valid value. This library is significantly less useful than amb for non-deterministic computing, but that doesn't seem to be the goal...
- d0m 11y agoYes, this is exactly what I was thinking about looking at the quantum example. For the end-user, it's the same high-level concept, but in the background the implementation is different. The quantum one create a new fork for each possible choice rather than using backtracking. The quantum example is interesting because it gives us a sneak peek into the future for where it will be possible to write similar code in O(1) time!!