--- /dev/null
+#lang racket
+
+#|
+
+In this original definition of amb-choices,
+
+(define (amb-choices expr) (rest expr))
+
+instead return the shuffled values
+
+(define (amb-choices expr) (shuffle (rest expr)))
+
+|#
\ No newline at end of file
--- /dev/null
+#lang racket
+
+;;; assignment
+(define (analyze-assignment expr)
+ (let ([var (assignment-var expr)]
+ [vproc (analyze (assignment-value expr))])
+ (lambda (env succeed fail)
+ (vproc env
+ (lambda (val fail2)
+ (let ([old-val (lookup-variable-value var env)])
+ (set-variable-value! var val)
+ (succeed 'ok
+ (lambda ()
+ (set-variable-value! var old-val env)
+ (fail2)))))
+ fail))))
+
+;; permenent-set!
+;;; assignment
+(define (analyze-permanent-assignment expr)
+ (let ([var (perm-assignment-var expr)]
+ [vproc (analyze (perm-assignment-value expr))])
+ (lambda (env succeed fail)
+ (vproc env
+ (lambda (val fail2)
+ (set-variable-value! var val)
+ (succeed 'ok fail2))
+ fail))))
--- /dev/null
+#lang racket
+
+;; if-fail
+
+(define (analyze-if-fail expr)
+ (let ([sproc (analyze (if-fail-success expr))]
+ [fproc (analyze (if-fail-failure expr))])
+ (lambda (env succeed fail)
+ (sproc env
+ succeed
+ (lambda ()
+ (fexpr env succeed fail))))))
\ No newline at end of file
--- /dev/null
+#lang racket
+
+(define (assert? expr) (tagged-list? expr 'assert))
+
+(define (assert-predicate expr) (first (rest expr)))
+
+(define (analyze-assert exp)
+ (let ((pproc (analyze (assert-predicate exp))))
+ (lambda (env succeed fail)
+ (pproc env
+ (lambda (pred-value fail2)
+ (if (not (true? pred-value))
+ (fail)
+ (succeed 'ok fail2)))
+ fail))))
\ No newline at end of file