File tree 2 files changed +26
-1
lines changed
2 files changed +26
-1
lines changed Original file line number Diff line number Diff line change 1
1
---
2
- refs/heads/master: 2dedcc8aa2e6c9eb5011dab2c22679f5ae8e35fc
2
+ refs/heads/master: cefa97dc2e2792871a91fe1d59dab26014fbc9d3
Original file line number Diff line number Diff line change @@ -94,7 +94,21 @@ pure fn is_whitespace(c: char) -> bool {
94
94
} else if c == ch_no_break_space { true } else { false }
95
95
}
96
96
97
+ /*
98
+ Function: to_digit
99
+
100
+ Convert a char to the corresponding digit.
101
+
102
+ Parameters:
103
+ c - a char, either '0' to '9', 'a' to 'z' or 'A' to 'Z'
97
104
105
+ Returns:
106
+ If `c` is between '0' and '9', the corresponding value between 0 and 9.
107
+ If `c` is 'a' or 'A', 10. If `c` is 'b' or 'B', 11, etc.
108
+
109
+ Safety note:
110
+ This function fails if `c` is not a valid char
111
+ */
98
112
pure fn to_digit ( c : char ) -> u8 {
99
113
alt c {
100
114
'0' to ' 9 ' { c as u8 - ( '0' as u8 ) }
@@ -104,7 +118,18 @@ pure fn to_digit(c: char) -> u8 {
104
118
}
105
119
}
106
120
121
+ /*
122
+ Function: cmp
123
+
124
+ Compare two chars.
107
125
126
+ Parameters:
127
+ a - a char
128
+ b - a char
129
+
130
+ Returns:
131
+ -1 if a<b, 0 if a==b, +1 if a>b
132
+ */
108
133
fn cmp ( a : char , b : char ) -> int {
109
134
ret if b > a { -1 }
110
135
else if b < a { 1 }
You can’t perform that action at this time.
0 commit comments