diff options
| author | Rose Hogenson <rhogenson@posteo.net> | 2022-08-07 15:50:28 -0700 |
|---|---|---|
| committer | Rose Hogenson <rhogenson@posteo.net> | 2022-08-07 15:50:28 -0700 |
| commit | faaf99cbe037d42f01228a302b69d7ddcacfe2f5 (patch) | |
| tree | 24a880bbeb6977cd5aa6161fc34bb1b049b360dd /lib/scheme/base/30-if.csc | |
| parent | Check that records are the correct type. (diff) | |
| download | chromatopelma-faaf99cbe037d42f01228a302b69d7ddcacfe2f5.tar.zst | |
Add booleans.
Diffstat (limited to 'lib/scheme/base/30-if.csc')
| -rw-r--r-- | lib/scheme/base/30-if.csc | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/lib/scheme/base/30-if.csc b/lib/scheme/base/30-if.csc index 6262f5a..36edc16 100644 --- a/lib/scheme/base/30-if.csc +++ b/lib/scheme/base/30-if.csc @@ -1,13 +1,17 @@ (export and + boolean=? + boolean? case-lambda cond if + not or unless when) (import (only (csc builtins) - builtin-if)) + builtin-if + call-builtin)) (begin @@ -100,4 +104,23 @@ . body) args) (cl . rest)))))) - (cl (params body0 ...) ...)))))))) + (cl (params body0 ...) ...))))))) + + + (define (not obj) + (if obj + #f + #t)) + + + (define (boolean? obj) + (call-builtin eq? 2 (call-builtin typeof obj))) + + + (define (boolean=? b1 b2 . bs) + (and (boolean? b1) + (let loop ((bs (cons b2 bs))) + (or (null? bs) + (and (boolean? (car bs)) + (call-builtin eq? b1 (car bs)) + (loop (cdr bs)))))))) |
