John McCarthy’s ambiguous operator for Racket, implemented via delimited continuations.
This repository contains two packages:
(require amb)
(for/list ([x (in-amb (amb 1 2 3))])
x)
;; => '(1 2 3)
(for/list ([t (in-amb (let ([a (for/amb ([i (in-range 1 20)]) i)]
[b (for/amb ([i (in-range 1 20)]) i)]
[c (for/amb ([i (in-range 1 20)]) i)])
(unless (and (<= a b)
(= (+ (* a a) (* b b)) (* c c)))
(amb))
(list a b c)))])
t)
;; => '((3 4 5) (5 12 13) (6 8 10) (8 15 17) (9 12 15))raco pkg install amb # untyped
raco pkg install typed-amb # typedAfter installation, run:
raco docs ambOr read the source documentation in pkgs/amb/scribblings/amb.scrbl.
MIT. See LICENSE.