From 8be0c02a06948e1a9359eeb122aa1671ff40f330 Mon Sep 17 00:00:00 2001 From: Justin Ethier Date: Wed, 25 Mar 2015 22:53:55 -0400 Subject: [PATCH] Added more char functions --- trans.scm | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/trans.scm b/trans.scm index 5ac64f0e..43aeecc2 100644 --- a/trans.scm +++ b/trans.scm @@ -72,9 +72,15 @@ (define (char>? c1 c2 . cs) (Cyc-bin-op-char > c1 (cons c2 cs))) (define (char<=? c1 c2 . cs) (Cyc-bin-op-char <= c1 (cons c2 cs))) (define (char>=? c1 c2 . cs) (Cyc-bin-op-char >= c1 (cons c2 cs))) - (define (char-whitespace? c) (member c '(#\tab #\space #\return #\newline))) + (define (char-alphabetic? c) (and (char>=? c #\A) (char<=? c #\z))) ;; ASCII-only + (define (char-upper-case? c) (and (char>=? c #\A) (char<=? c #\Z))) ;; ASCII-only + (define (char-lower-case? c) (and (char>=? c #\a) (char<=? c #\z))) ;; ASCII-only (define (char-numeric? c) (member c '(#\0 #\1 #\2 #\3 #\4 #\5 #\6 #\7 #\8 #\9))) - ; TODO: implement in terms of char>? procs ==> (define (char-upper-case? c) + (define (char-whitespace? c) (member c '(#\tab #\space #\return #\newline))) + (define (digit-value c) + (if (char-numeric? c) + (- (char->integer c) (char->integer #\0)) + #f)) (define (foldl func accum lst) (if (null? lst) accum