From 249061982f6e23bfa7eb48ce3eb4f9f568f0d75e Mon Sep 17 00:00:00 2001 From: Yuichi Nishiwaki Date: Thu, 14 Nov 2013 16:52:10 +0900 Subject: [PATCH] =?UTF-8?q?add=20symbol=3D=3F=20function?= --- README.md | 2 +- piclib/built-in.scm | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 3cbdc42c..ab481020 100644 --- a/README.md +++ b/README.md @@ -67,7 +67,7 @@ | 6.2.7 Numerical input and output | no | | | 6.3 Booleans | yes | | | 6.4 Pairs and lists | yes | | -| 6.5 Symbols | incomplete | TODO: `symbol=?`, `symbol->string`, `string->symbol` | +| 6.5 Symbols | yes | | | 6.6 Characters | incomplete | TODO: almost all functions in the section :-( | | 6.7 Strings | incomplete | | | 6.8 Vectors | incomplete | TODO: `vector-copy`, ...etc | diff --git a/piclib/built-in.scm b/piclib/built-in.scm index e98b043b..9eea4614 100644 --- a/piclib/built-in.scm +++ b/piclib/built-in.scm @@ -254,3 +254,19 @@ #f))) (or (every (lambda (x) (eq? x #t)) objs) (every (lambda (x) (eq? x #f)) objs))) + + +(define (symbol=? . objs) + (define (every pred list) + (if (null? list) + #t + (if (pred (car list)) + (every pred (cdr list)) + #f))) + (let ((sym (car objs))) + (if (symbol? sym) + (every (lambda (x) + (and (symbol? x) + (eq? x sym))) + (cdr objs)) + #f)))