From 6296d4bee21710f837685e8adf45c1804ee289d5 Mon Sep 17 00:00:00 2001 From: Yuichi Nishiwaki Date: Thu, 14 Nov 2013 14:31:57 +0900 Subject: [PATCH] =?UTF-8?q?add=20boolean=3D=3F?= --- README.md | 2 +- piclib/built-in.scm | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 04f53a68..7d986ddb 100644 --- a/README.md +++ b/README.md @@ -65,7 +65,7 @@ | 6.2.5 Syntax of numerical constants | yes | | | 6.2.6 Numerical operations | yes | some functions that return multiple values are not supported for now. Also, picrin does not provide complex library procedures. | | 6.2.7 Numerical input and output | no | | -| 6.3 Booleans | incomplete | TODO: `boolean=?` | +| 6.3 Booleans | yes | | | 6.4 Pairs and lists | yes | | | 6.5 Symbols | incomplete | TODO: `symbol=?`, `symbol->string`, `string->symbol` | | 6.6 Characters | incomplete | TODO: almost all functions in the section :-( | diff --git a/piclib/built-in.scm b/piclib/built-in.scm index 6a27bf5b..e98b043b 100644 --- a/piclib/built-in.scm +++ b/piclib/built-in.scm @@ -244,3 +244,13 @@ (eq? '*values-tag* (car res))) (apply consumer (cdr res)) (consumer res)))) + +(define (boolean=? . objs) + (define (every pred list) + (if (null? list) + #t + (if (pred (car list)) + (every pred (cdr list)) + #f))) + (or (every (lambda (x) (eq? x #t)) objs) + (every (lambda (x) (eq? x #f)) objs)))