mirror of
https://github.com/HigherOrderCO/Kind1.git
synced 2024-09-11 08:45:32 +03:00
improved String.to_nat
This commit is contained in:
parent
4b7417d8f1
commit
85e1c2f101
@ -1,10 +1,8 @@
|
||||
String.is_nat(s: String): Bool
|
||||
String.is_nat.aux(s, true)
|
||||
|
||||
String.is_nat.aux(s: String, aux: Bool): Bool
|
||||
case s {
|
||||
nil : aux
|
||||
cons:
|
||||
let is_digit = Bool.and(Char.is_digit(s.head),aux)
|
||||
String.is_nat.aux(s.tail, is_digit)
|
||||
String.is_nat(str: String): Bool
|
||||
case str {
|
||||
nil: true
|
||||
cons: case Char.is_digit(str.head) {
|
||||
true: String.is_nat(str.tail)
|
||||
false: false
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user