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;
intonamespaceGeneric
{
publicclassStack<T>
{
List<T> items = newList<T>();
public:
Push(T item) { items.Add(item); }
Pop() : T => items.Pop();
i32Count { get => items.Count; }
}
Largest<T : IComparable<T>>(T a, T b) : T => a.CompareTo(b) >= 0 ? a : b;
Sum<T : number>(T[] values) : T
{
T total = T.Zero;
loop (T v in values)
total = total + v;
return total;
}
Main()
{
Stack<str> stack = newStack<str>();
stack.Push("a");
stack.Push("b");
Console.WriteLine(stack.Pop() + " " + stack.Count);
Console.WriteLine(Largest("pear", "apple"));
Console.WriteLine(Largest(3, 7));
Console.WriteLine(Sum([1, 2, 3]));
Console.WriteLine(Sum([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.