Something went wrong. Try again.
A general purpose .. programming language written in zig ijadux2.tngl.sh/Rinnescript
zig language
Something went wrong. Try again.
1.0 kB · 32 lines
1234567891011121314151617181920212223242526272829303132// test.rg — quick verification / scratch example//// Exercises several everyday constructs in one file so you can confirm the// toolchain is healthy: user functions, integer/float casts, file I/O,// array element access, function calls inside formatted output, and the// default `main` return value becoming the exit code.//// Run: rinne run examples/test.rg// echo $? # -> 0@import = .{ std };fn add(a: int, b: int) int { return a + b;}pub fn main() int { const x: int = 20; // float -> int truncates toward zero, exactly like @as(int, 300.10). const flex: int = @as(int, 300.10); // 300 std.print("hello {} {}\n", .{ x, x + flex }); // 20 320 std.print("fn-call add(20, 20) = {}\n", .{add(20, 20)}); // 40 // File I/O round-trip. const wrote = std.io.write_file("/tmp/rinne_test.txt", "ok"); const got = std.io.read_file("/tmp/rinne_test.txt"); std.print("wrote={} file says=\"{}\"\n", .{ wrote, got }); return 0;}