lisp

solutions to Lisp in Small Pieces
Log | Files | Refs | Feed

commit f818bdebb664cab90a885062b8ff5ed49bf74f5d
parent e476ad88842413f6428c9586a43517ef45492fc9
Author: Jenny Doe <tng@soykaf.me>
Date:   Mon,  7 Jan 2019 22:08:47 +0100

The false value

Diffstat:
Mchapter1/d.evaluate.scm | 3++-
Mchapter1/evaluate.scm | 4+++-
Achapter1/false.scm | 2++
3 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/chapter1/d.evaluate.scm b/chapter1/d.evaluate.scm @@ -14,7 +14,8 @@ env)) ((begin) (eprogn (cdr exp) env)) ((set!) (update! (cadr exp) (evaluate (caddr exp) env) env)) - ((if) (if (evaluate (cadr exp) env) + ((if) (if (not (eq? (evaluate (cadr exp) env) + the-false-value)) (evaluate (caddr exp) env) (evaluate (cadddr exp) env))) ;((exit) (exit (cadr exp))) diff --git a/chapter1/evaluate.scm b/chapter1/evaluate.scm @@ -1,5 +1,6 @@ (load "environment.scm") (load "procedures.scm") +(load "false.scm") (define (evaluate exp env) (if (atom? exp) ; (not (pair? exp)) @@ -15,7 +16,8 @@ env)) ((begin) (eprogn (cdr exp) env)) ((set!) (update! (cadr exp) (evaluate (caddr exp) env) env)) - ((if) (if (evaluate (cadr exp) env) + ((if) (if (not (eq? (evaluate (cadr exp) env) + the-false-value)) (evaluate (caddr exp) env) (evaluate (cadddr exp) env))) ;((exit) (exit (cadr exp))) diff --git a/chapter1/false.scm b/chapter1/false.scm @@ -0,0 +1,2 @@ +(define the-false-value + (cons "false" "boolean"))