boot2

Playing with the boostrap
git clone https://git.ryansepassi.com/git/boot2.git
Log | Files | Refs | README

100-char-procs.scm (2483B)


      1 ; char?, char->integer, integer->char, digit-value, char predicates,
      2 ; case maps, and the variadic char comparisons.
      3 
      4 ;; --- char? is a fixnum 0..255 range check --------------------------
      5 (if (char? #\A)         0 (sys-exit 1))
      6 (if (char? 0)           0 (sys-exit 2))
      7 (if (char? 255)         0 (sys-exit 3))
      8 (if (not (char? -1))    0 (sys-exit 4))
      9 (if (not (char? 256))   0 (sys-exit 5))
     10 (if (not (char? 'sym))  0 (sys-exit 6))
     11 
     12 ;; --- char->integer / integer->char are the identity ---------------
     13 (if (= 65 (char->integer #\A)) 0 (sys-exit 7))
     14 (if (= #\A (integer->char 65)) 0 (sys-exit 8))
     15 (if (eq? #\A 65)               0 (sys-exit 9))
     16 
     17 ;; --- digit-value --------------------------------------------------
     18 (if (= 0 (digit-value #\0))    0 (sys-exit 10))
     19 (if (= 9 (digit-value #\9))    0 (sys-exit 11))
     20 (if (eq? #f (digit-value #\A)) 0 (sys-exit 12))
     21 
     22 ;; --- char predicates ----------------------------------------------
     23 (if (char-alphabetic? #\Z)        0 (sys-exit 13))
     24 (if (char-alphabetic? #\a)        0 (sys-exit 14))
     25 (if (not (char-alphabetic? #\5))  0 (sys-exit 15))
     26 (if (char-numeric? #\7)           0 (sys-exit 16))
     27 (if (not (char-numeric? #\A))     0 (sys-exit 17))
     28 (if (char-whitespace? #\space)    0 (sys-exit 18))
     29 (if (char-whitespace? #\tab)      0 (sys-exit 19))
     30 (if (char-whitespace? #\newline)  0 (sys-exit 20))
     31 (if (not (char-whitespace? #\A))  0 (sys-exit 21))
     32 (if (char-upper-case? #\K)        0 (sys-exit 22))
     33 (if (not (char-upper-case? #\k))  0 (sys-exit 23))
     34 (if (char-lower-case? #\k)        0 (sys-exit 24))
     35 (if (not (char-lower-case? #\K))  0 (sys-exit 25))
     36 
     37 ;; --- case maps (ASCII; non-letters unchanged) --------------------
     38 (if (eq? #\A (char-upcase #\a))   0 (sys-exit 26))
     39 (if (eq? #\A (char-upcase #\A))   0 (sys-exit 27))
     40 (if (eq? #\7 (char-upcase #\7))   0 (sys-exit 28))
     41 (if (eq? #\a (char-downcase #\A)) 0 (sys-exit 29))
     42 (if (eq? #\a (char-downcase #\a)) 0 (sys-exit 30))
     43 (if (eq? #\a (char-foldcase #\A)) 0 (sys-exit 31))
     44 
     45 ;; --- variadic char comparisons -----------------------------------
     46 (if (char=? #\a #\a)           0 (sys-exit 32))
     47 (if (char=? #\a #\a #\a #\a)   0 (sys-exit 33))
     48 (if (not (char=? #\a #\a #\b)) 0 (sys-exit 34))
     49 (if (char<? #\a #\b)           0 (sys-exit 35))
     50 (if (char<? #\a #\b #\c)       0 (sys-exit 36))
     51 (if (not (char<? #\a #\b #\b)) 0 (sys-exit 37))
     52 (if (char>? #\c #\b #\a)       0 (sys-exit 38))
     53 (if (char<=? #\a #\b #\b #\c)  0 (sys-exit 39))
     54 (if (char>=? #\c #\c #\b #\a)  0 (sys-exit 40))
     55 
     56 (sys-exit 41)