Files use .rex, the command is rex, and the crate, runtime prefixes, docs, editor files and examples all use the new name. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
38 lines
967 B
Rexx
38 lines
967 B
Rexx
struct Tok { first: char }
|
|
|
|
func kind(c: char): string {
|
|
return match c {
|
|
'+' => "plus"
|
|
'\n' => "newline"
|
|
' ' => "space"
|
|
_ => "other"
|
|
}
|
|
}
|
|
|
|
func main() {
|
|
var c = 'a'
|
|
print(c, c == 'a', c < 'b', int(c), char(66), string(c) + "!")
|
|
var s = "héllo wörld 42"
|
|
var letters = 0
|
|
var digits = 0
|
|
for ch in s {
|
|
if ch.is_letter() { letters += 1 }
|
|
if ch.is_digit() { digits += 1 }
|
|
}
|
|
print(letters, digits, s.len())
|
|
for i, ch in "aé😀" { print(i, ch) }
|
|
print(s[0], s[1], s[3], s[s.len() - 1])
|
|
var up = ""
|
|
for ch in "rex" { up += string(ch.upper()) }
|
|
print(up, 'Q'.lower(), kind('+'), kind('\n'), kind('z'))
|
|
var counts: map[char, int] = {}
|
|
for ch in "banana" { counts[ch] += 1 }
|
|
print(counts)
|
|
var w = ""
|
|
for ch in "a b c" {
|
|
if ch == ' ' { continue }
|
|
w += string(ch)
|
|
}
|
|
print(w, 'a'.is_alnum(), ' '.is_space(), 'A'.is_upper())
|
|
}
|