36 lines
770 B
Plaintext
36 lines
770 B
Plaintext
|
|
static box StringUtils {
|
||
|
|
is_digit(ch) {
|
||
|
|
return ch == "0" or ch == "1" or ch == "2" or ch == "3" or ch == "4"
|
||
|
|
or ch == "5" or ch == "6" or ch == "7" or ch == "8" or ch == "9"
|
||
|
|
}
|
||
|
|
|
||
|
|
is_integer(s) {
|
||
|
|
if s.length() == 0 {
|
||
|
|
return false
|
||
|
|
}
|
||
|
|
|
||
|
|
local start = 0
|
||
|
|
if s.substring(0, 1) == "-" {
|
||
|
|
if s.length() == 1 {
|
||
|
|
return false
|
||
|
|
}
|
||
|
|
start = 1
|
||
|
|
}
|
||
|
|
|
||
|
|
local i = start
|
||
|
|
loop(i < s.length()) {
|
||
|
|
if not this.is_digit(s.substring(i, i + 1)) {
|
||
|
|
return false
|
||
|
|
}
|
||
|
|
i = i + 1
|
||
|
|
}
|
||
|
|
return true
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
static box Main {
|
||
|
|
main() {
|
||
|
|
return StringUtils.is_integer("123") ? 7 : 1
|
||
|
|
}
|
||
|
|
}
|