Write Antril, run it in your browser and share it with a link. Programs are compiled to WebAssembly and run on your machine, not on the server.
Running programs is unavailable right now: the WebAssembly linker (wasm-ld, part of LLVM) is not installed on this server. You can still write, share and download code.
importSystem;
publicvalueN
{
public:
i64X;
new(i64X);
op +(N a, N b) : N => newN(a.X + b.X);
op *(N a, N b) : N => newN(a.X * b.X);
op ^^(N a, N b) : Nprecedence(PrecedenceLevel.Power) associativity(Associativity.Right)
{
i64 r = 1;
loop (i64 i = 0..b.X)
r = r * a.X;
returnnewN(r);
}
op <=>(N a, N b) : i32precedence(PrecedenceLevel.Relational) associativity(Associativity.None)
=> a.X < b.X ? -1 : a.X > b.X ? 1 : 0;
op <*>(N a, N b) : Nprecedence(135) => newN(a.X * 100 + b.X);
}
Main()
{
N two = newN(2);
N three = newN(3);
Console.WriteLine((two ^^ three ^^ two).X);
Console.WriteLine(two <=> three);
Console.WriteLine((two + two <*> two * three).X);
}
Output
Press Run (or Ctrl+Enter) to compile and run the program.
Input
What Console.ReadLine() reads, one line at a time.
Ctrl+Enter runs. Tab indents (Shift+Tab outdents); press Esc, then Tab, to leave the editor. A program may run for 10 seconds.