Initial Commit
This commit is contained in:
782 files changed
+145156
No files matched your search
@@ -0,0 +1,24 @@
|
||||
import std::io;
|
||||
struct counter { var count: int; }
|
||||
def bump(value: &mut int, by: &i32): void { value += by; value++; }
|
||||
def swap(a: &mut int, b: &mut int): void { val t := a + 0; a = b; b = t; }
|
||||
def set(maybe: *mut int): void { if maybe != null { maybe[0] = 42; } }
|
||||
def main(): void {
|
||||
var n := 1;
|
||||
val step: i32 = 5;
|
||||
bump(&mut n, &step);
|
||||
var x := 10;
|
||||
var y := 20;
|
||||
swap(&mut x, &mut y);
|
||||
var c := counter{3};
|
||||
bump(&mut c.count, &step);
|
||||
var values := [1, 2, 3];
|
||||
for &mut v in values { v = v * v; }
|
||||
val first := &mut values[0];
|
||||
first += 100;
|
||||
set(&mut y as *mut int);
|
||||
set(null);
|
||||
var r := &x;
|
||||
r = &y;
|
||||
println($"{n} {x} {y} {c.count} {values} {-first} {r + 0} {r == 42}");
|
||||
}
|
||||
Reference in new issue
Block a user