--- /dev/null
+#lang racket
+
+#|
+
+Yes, if 'unless' were implemented in an applicative order language, then
+it would be implemented as a special form and would be translated into
+other functions before evaluation.
+
+Now, if such a special form is used in a higher order function like 'map'
+for instance:
+
+(map unless '((p-list) (usual-list) (exception-list)))
+
+then, unless gets expanded before evaluation. But map expects a function
+as its second argument.
+
+To see the implementation of unless, see metacircular2.rkt
+
+|#
1
(* (factorial (- n 1)) n)))
env1)
- (check-equal? (eval '(factorial 10) env1) 3628800 "factorial test"))))
+ (check-equal? (eval '(factorial 10) env1) 3628800 "factorial test")
+ (check-equal? (eval '(unless true "true" "false") env1) "false" "unless test 1"))))
(run-tests metacircular2-tests)
\ No newline at end of file
[`(define ,(? (lambda (x) (not (pair? x))) var) ,b) (define-variable! var (eval b env) env)]
[`(define ,(? pair? var) ,b ..1) (define-variable! (car var) (eval (make-lambda (cdr var) b) env) env)]
[`(if ,pred ,consequent ,alternative) (if (true? (eval pred env)) (eval consequent env) (eval alternative env))]
+ [`(unless ,condition ,consequent ,alternative) (if (true? (eval condition env)) (eval alternative env) (eval consequent env))]
[`(lambda ,parameters ,body ..1) (make-procedure parameters body env)]
[`(begin ,exp ...) (eval-sequence exp env)]
[`(cond ,clauses ...) (eval (cond->if clauses) env)]