2021-07-18 09:00:20 +03:00
|
|
|
module builtin
|
|
|
|
|
|
|
|
pub fn (b byte) is_space() bool {
|
|
|
|
mut result := false
|
2021-08-25 14:40:53 +03:00
|
|
|
#result.val = /^\s*$/.test(String.fromCharCode(b))
|
|
|
|
|
|
|
|
return result
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn (c byte) is_letter() bool {
|
|
|
|
result := false
|
|
|
|
|
|
|
|
#result.val = (c.val >= `a`.charCodeAt() && c.val <= `z`.charCodeAt()) || (c.val >= `A`.charCodeAt() && c.val <= `Z`.charCodeAt())
|
2021-07-18 09:00:20 +03:00
|
|
|
|
|
|
|
return result
|
|
|
|
}
|
2021-09-08 20:30:46 +03:00
|
|
|
|
|
|
|
pub fn (c byte) str() string {
|
|
|
|
res := ''
|
|
|
|
#res.str = c.val.toString()
|
|
|
|
|
|
|
|
return res
|
|
|
|
}
|
2021-10-03 10:08:21 +03:00
|
|
|
|
|
|
|
pub fn (c byte) ascii_str() string {
|
|
|
|
res := ''
|
|
|
|
#res.str = String.fromCharCode(c.val)
|
|
|
|
|
|
|
|
return res
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn (c byte) repeat(count int) string {
|
|
|
|
mut res := ''
|
|
|
|
for _ in 0 .. count {
|
|
|
|
res += c.ascii_str()
|
|
|
|
}
|
|
|
|
|
|
|
|
return res
|
|
|
|
}
|