tisp

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

commit 83730aaf22837f78d1b43c0a74f34fddc2d56fa0
parent 1171d2e4fe06981888a5cb2c290bd325c535dd84
Author: Ed van Bruggen <edvb@uw.edu>
Date:   Wed, 18 Mar 2020 22:40:52 -0700

Add pair procedure to convert type to pair

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

diff --git a/tibs/lib.tsp b/tibs/lib.tsp @@ -59,6 +59,17 @@ (define (number? x) (or (rational? x) (decimal? x))) (define (bool x) (if x t nil)) +; TODO handle string and sym +(define (pair x) + (cond + ((rational? x) + (cons (numerator x) + (denominator x))) + ((decimal? x) + (cons (integer (truncate x)) + (- x (truncate x)))) + ((or (void? x) (nil? x) (pair? x)) x) + (else (list x)))) (defmacro (assert expr) `(unless ,expr