X-Git-Url: https://git.rkrishnan.org/?p=sicp.git;a=blobdiff_plain;f=src%2Fsicp%2Fex4_38.rkt;fp=src%2Fsicp%2Fex4_38.rkt;h=e705ef0c02d843924012f5e40fd9856b69727a95;hp=0000000000000000000000000000000000000000;hb=50cef372de91c41185de4fac8a1fc456c978b28a;hpb=07f6c2a14b01e1a1f9c585c8a53086fbb819f8f8 diff --git a/src/sicp/ex4_38.rkt b/src/sicp/ex4_38.rkt new file mode 100644 index 0000000..e705ef0 --- /dev/null +++ b/src/sicp/ex4_38.rkt @@ -0,0 +1,34 @@ +#lang racket + +(require "amb-eli.rkt") +(require "distinct.rkt") + +(define (multiple-dwelling) + (let ([baker (amb 1 2 3 4 5)] + [cooper (amb 1 2 3 4 5)] + [fletcher (amb 1 2 3 4 5)] + [miller (amb 1 2 3 4 5)] + [smith (amb 1 2 3 4 5)]) + (assert (distinct? (list baker cooper fletcher miller smith))) + (assert (not (= baker 5))) + (assert (not (= cooper 1))) + (assert (not (= fletcher 5))) + (assert (not (= fletcher 1))) + (assert (> miller cooper)) + ;; (assert (not (= (abs (- smith fletcher)) 1))) + (assert (not (= (abs (- fletcher cooper)) 1))) + (list (list 'baker baker) + (list 'cooper cooper) + (list 'fletcher fletcher) + (list 'miller miller) + (list 'smith smith)))) + +(collect (multiple-dwelling)) + +#| +'(((baker 1) (cooper 2) (fletcher 4) (miller 3) (smith 5)) + ((baker 1) (cooper 2) (fletcher 4) (miller 5) (smith 3)) + ((baker 1) (cooper 4) (fletcher 2) (miller 5) (smith 3)) + ((baker 3) (cooper 2) (fletcher 4) (miller 5) (smith 1)) + ((baker 3) (cooper 4) (fletcher 2) (miller 5) (smith 1))) +|# \ No newline at end of file