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>
This commit is contained in:
1 parent
2f44f09b6a
commit
7cf9727bcd
94 files changed
+858
-858
No files matched your search
@@ -0,0 +1,50 @@
|
||||
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")
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user