Files
rexlang/examples/basics/sized.rex
T
Your NameandClaude Opus 5.5 7cf9727bcd Rename the language from Dino to Rex
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>
2026-11-08 13:51:23 +01:00

51 lines
1.1 KiB
Rexx

struct Vec2 {
x, y: f32
func add(b: Vec2): Vec2 { return Vec2{x + b.x, y + b.y} }
func scale(k: f32): Vec2 { return Vec2{x * k, y * k} }
}
func average(a: u8, b: u8): u8 {
return u8((int(a) + int(b)) / 2)
}
func main() {
// literals take the type that is asked for
var small: u8 = 250
small += 10 // wraps around: 260 becomes 4
print(small)
var id: i8 = -128
print(id, id - 1)
var big: u64 = 5
big = big * 1000000000000
print(big, big / 7, big % 7)
var n: i32 = 2147483647
print(n + 1)
// f32 prints the shortest text that reads back the same
var speed: f32 = 1.1
print(speed, speed * 2, speed / 3)
var v = Vec2{1.5, 2}
print(v.add(Vec2{0.25, 0.25}).scale(2))
// conversions are explicit
var f = 3.99
print(int(f), u8(f), i8(-200.5), u8(300.7), f32(f))
print(u8(300), i16(70000), u32(-1), int(small) + 1)
print(average(200, 100))
print(u8(7) == 7, small < 10)
var xs: []u8 = [1, 2, 255]
xs[2] += 1
print(xs)
match id {
-128 => print("lowest i8")
_ => print("other")
}
}