tisp

tiny lisp
git clone git://edryd.org/tisp
Log | Files | Refs | LICENSE

commit 6c19b7d5ebce15e627069f23316023ec15b38575
parent 97f1ccbe65c361638b09a655691b95f9de2c25cb
Author: Ed van Bruggen <edvb@uw.edu>
Date:   Fri,  6 Sep 2019 16:34:54 -0700

Add list boolean functions empty? cons? and pair?

Diffstat:
tibs/lib.tsp | 3+++
1 file changed, 3 insertions(+), 0 deletions(-)

diff --git a/tibs/lib.tsp b/tibs/lib.tsp @@ -33,6 +33,7 @@ ;;; Types (define (void? x) (= (type x) "void")) (define (nil? x) (= (type x) "nil")) +(define empty? nil?) (define (integer? x) (= (type x) "integer")) (define (decimal? x) (= (type x) "decimal")) (define (ratio? x) (= (type x) "ratio")) @@ -41,6 +42,8 @@ (define (primitive? x) (= (type x) "primitive")) (define (function? x) (= (type x) "function")) (define (pair? x) (= (type x) "pair")) +(define cons? pair?) +(define (list? x) (and (pair? x) (pair? (cdr x)))) (define (boolean? x) (or (= x t) (nil? x))) (define (true? x) (= x t)) (define false? nil?)