tisp

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

commit a74e80895b736f9cd0806cfe4707511829f41a43
parent 70155e880d583a4494b6fb9c31f794e3684b321e
Author: Ed van Bruggen <edvb@uw.edu>
Date:   Wed, 26 Jun 2019 01:53:13 -0700

Standard boolean, zero, even, and odd tests

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

diff --git a/tibs/lib.tsp b/tibs/lib.tsp @@ -39,6 +39,7 @@ (define (primitive? x) (= (type x) "primitive")) (define (function? x) (= (type x) "function")) (define (pair? x) (= (type x) "pair")) +(define (boolean? x) (or (= x t) (nil? x))) (define (rational? x) (or (integer? x) (ratio? x))) (define (number? x) (or (rational? x) (decimal? x))) @@ -109,6 +110,9 @@ (define (positive? x) (> x 0)) (define (negative? x) (< x 0)) +(define (zero? x) (= x 0)) +(define (even? x) (= (mod x 2) 0)) +(define (odd? x) (= (mod x 2) 1)) (define (! n) (if (= n 1)