-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathutils-char.stanza
More file actions
31 lines (23 loc) · 783 Bytes
/
utils-char.stanza
File metadata and controls
31 lines (23 loc) · 783 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
defpackage utils/char :
import core
public defn digit? (c:Int) -> True|False :
c >= to-int('0') and c <= to-int('9')
public defn lower? (c:Int) -> True|False :
c >= to-int('a') and c <= to-int('z')
public defn upper? (c:Int) -> True|False :
c >= to-int('A') and c <= to-int('Z')
public defn printable? (c:Int) -> True|False :
c >= to-int(' ') and c <= to-int('~')
public defn upper-case (c:Int) -> Int :
if lower?(c) :
c - to-int('a') + to-int('A')
else :
c
public defn lower-case (c:Int) -> Int :
if upper?(c) :
c - to-int('A') + to-int('a')
else :
c
;; public defn digit? (c:Char) -> True|False : digit?(to-int(c))
public defn lower? (c:Char) -> True|False : lower?(to-int(c))
public defn upper? (c:Char) -> True|False : upper?(to-int(c))