blob: 75a0ab3394b5ef4a3fb6eb5346da9613fc2ec4d8 (
plain) (
blame)
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
# MIT License, Copyright (c) 2023 Marvin Borner
:input std/Number/Binary
:import std/Number/Conversion .
# prefix for comparing functions
?‣ &eq?
# converts a char to a balanced ternary number
char→number (\sub '0') → binary→ternary ⧗ Char → Number
:test (char→number '0') ((+0))
# converts a balanced ternary number to a char
number→char ternary→binary → (add '0') ⧗ Number → Char
:test (number→char (+0)) ('0')
:test (number→char (+9)) ('9')
# returns true if char is in A-Z
uppercase? φ and? (\geq? 'A') (\leq? 'Z') ⧗ Char → Boolean
:test (uppercase? 'a') (false)
:test (uppercase? 'z') (false)
:test (uppercase? 'A') (true)
:test (uppercase? 'Z') (true)
:test (uppercase? '0') (false)
# returns true if char is in a-z
lowercase? φ and? (\geq? 'a') (\leq? 'z') ⧗ Char → Boolean
:test (lowercase? 'a') (true)
:test (lowercase? 'z') (true)
:test (lowercase? 'A') (false)
:test (lowercase? 'Z') (false)
:test (lowercase? '0') (false)
# returns true if char is in a-zA-Z
alpha? φ or? lowercase? uppercase? ⧗ Char → Boolean
:test (alpha? 'a') (true)
:test (alpha? 'z') (true)
:test (alpha? 'A') (true)
:test (alpha? 'Z') (true)
:test (alpha? '0') (false)
# returns true if char is in 0-9
numeric? φ and? (\geq? '0') (\leq? '9') ⧗ Char → Boolean
:test (numeric? '0') (true)
:test (numeric? '9') (true)
:test (numeric? 'a') (false)
# returns true if char is in a-zA-Z0-9
alpha-numeric? φ or? numeric? alpha? ⧗ Char → Boolean
:test (alpha-numeric? 'a') (true)
:test (alpha-numeric? 'z') (true)
:test (alpha-numeric? 'A') (true)
:test (alpha-numeric? 'Z') (true)
:test (alpha-numeric? '0') (true)
:test (alpha-numeric? '9') (true)
:test (alpha-numeric? '$') (false)
|