aboutsummaryrefslogtreecommitdiffstats
path: root/lib/scheme/base/30-if.csc
diff options
context:
space:
mode:
authorRose Hogenson <rhogenson@posteo.net>2022-08-07 15:50:28 -0700
committerRose Hogenson <rhogenson@posteo.net>2022-08-07 15:50:28 -0700
commitfaaf99cbe037d42f01228a302b69d7ddcacfe2f5 (patch)
tree24a880bbeb6977cd5aa6161fc34bb1b049b360dd /lib/scheme/base/30-if.csc
parentCheck that records are the correct type. (diff)
downloadchromatopelma-faaf99cbe037d42f01228a302b69d7ddcacfe2f5.tar.zst
Add booleans.
Diffstat (limited to 'lib/scheme/base/30-if.csc')
-rw-r--r--lib/scheme/base/30-if.csc27
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))))))))