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;
publicclassThing
{
public:
i32Id = 7;
}
Twice<T : op +(T, T) : T>(T x) : T => x + x;
Make<T : new()>() : T => newT();
Bits<T : int>(T x) : i32 => (i32)sizeof(T) * 8;
Doubled<T : [u8, u16]>(T x) : T => x + x;
Zero<T : plain>() : T => default(T);
Total<T : number>(T[] values) : T
{
T sum = T.Zero;
loop (T v in values)
sum = sum + v;
return sum;
}
Main()
{
Console.WriteLine(Twice(21) + " " + Twice(1.25));
Console.WriteLine(Make<Thing>().Id);
Console.WriteLine(Bits<i16>(1) + " " + Doubled<u8>(200) + " " + Zero<f64>());
Console.WriteLine(Total([1, 2, 3]) + " " + Total([1.5, 2.25]));
}
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.