X-Git-Url: https://git.rkrishnan.org/?p=sicp.git;a=blobdiff_plain;f=src%2Fsicp%2Fex4_54.rkt;fp=src%2Fsicp%2Fex4_54.rkt;h=79dcb0c9e20357b29ef5a9cb5b04083915bb298b;hp=0000000000000000000000000000000000000000;hb=5158bd64ca487b858c9d95e8a2bccb81fe2113a7;hpb=273f2bd230187a3164803ac32d9b5734d0123ad0 diff --git a/src/sicp/ex4_54.rkt b/src/sicp/ex4_54.rkt new file mode 100644 index 0000000..79dcb0c --- /dev/null +++ b/src/sicp/ex4_54.rkt @@ -0,0 +1,15 @@ +#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