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;
publicvalueMoney
{
public:
i64Cents;
new(i64Cents);
op +(Money a, Money b) : Money => newMoney(a.Cents + b.Cents);
op -(Money a) : Money => newMoney(-a.Cents);
op *(Money a, i64 k) : Money => newMoney(a.Cents * k);
op ==(Money a, Money b) : bool => a.Cents == b.Cents;
op <(Money a, Money b) : bool => a.Cents < b.Cents;
op ++(Money a) : Money => newMoney(a.Cents + 1);
op (i64)(Money m) => m.Cents;
op (Money)(i64 cents) => newMoney(cents);
}
Main()
{
Money a = newMoney(150);
Money b = newMoney(250);
Console.WriteLine((a + b).Cents + " " + (-a).Cents + " " + (a * 3).Cents);
Console.WriteLine((a == b) + " " + (a != b) + " " + (a < b));
a++;
++a;
Console.WriteLine((i64)a);
Money c = (Money)99i64;
Console.WriteLine(c.Cents);
}
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.