From 0ca4d3f4b5129e6bebb256a0e0a0b77e4cef1dcd Mon Sep 17 00:00:00 2001 From: Justin Ethier Date: Thu, 31 Mar 2016 22:31:05 -0400 Subject: [PATCH] Added string-ci's --- scheme/char.sld | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/scheme/char.sld b/scheme/char.sld index 5aa4d1aa..d03f44f1 100644 --- a/scheme/char.sld +++ b/scheme/char.sld @@ -24,11 +24,12 @@ digit-value string-upcase string-downcase - ; TODO: - ;string-foldcase - ;string-ci<=? string-ci=? - ;string-ci>? + string-foldcase + string-ci<=? + string-ci=? + string-ci>? ) (import (scheme base)) (begin @@ -52,6 +53,11 @@ (define (char-ci=? c1 c2 . cs) (apply char>=? (map char-foldcase (cons c1 (cons c2 cs))))) (define (char-ci>? c1 c2 . cs) (apply char>? (map char-foldcase (cons c1 (cons c2 cs))))) + (define (string-ci=? s1 s2) (apply string=? (map string-foldcase (list s1 s2)))) + (define (string-ci? s1 s2) (apply string>? (map string-foldcase (list s1 s2)))) + (define (string-ci>=? s1 s2) (apply string>=? (map string-foldcase (list s1 s2)))) (define (char-alphabetic? c) (or (char-upper-case? c) (char-lower-case? c))) (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 @@ -63,4 +69,5 @@ #f)) (define (string-upcase str) (string-map char-upcase str)) (define (string-downcase str) (string-map char-downcase str)) + (define (string-foldcase str) (string-map char-foldcase str)) ))