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;
publicbaseclassShape { }
publicclassCircle : Shape
{
public:
f64Radius;
new(f64Radius);
}
publicclassRect : Shape
{
public:
f64W;
f64H;
new(f64W, f64H);
}
Describe(Shape s) : str => s switch
{
Circle c when c.Radius > 10 => "a big circle",
Circle c => "a circle of radius " + c.Radius,
Rect { W: 0 } orRect { H: 0 } => "a flat rectangle",
Rect r => "a rectangle " + r.W + "x" + r.H,
_ => "something else",
};
Main()
{
Console.WriteLine(Describe(newCircle(20)));
Console.WriteLine(Describe(newCircle(2)));
Console.WriteLine(Describe(newRect(0, 4)));
Console.WriteLine(Describe(newRect(2, 3)));
}
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.