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;
publicclassBag
{
List<str> items = newList<str>();
public:
Add(str s) { items.Add(s); }
Each() : Iterator<str>
{
loop (str s in items)
{
if (s == "stop")
yield break;
yield s;
}
}
}
Evens(i32 limit) : Iterator<i32>
{
loop (i32 i = 0..limit)
if (i % 2 == 0)
yield i;
}
Main()
{
Bag b = newBag();
b.Add("a");
b.Add("b");
b.Add("stop");
b.Add("c");
loop (str s in b.Each())
Console.Write(s);
Console.WriteLine();
Iterator<i32> it = Evens(7);
it.Next();
Console.WriteLine(it.Current);
loop (i32 e in it)
Console.Write(e + " ");
Console.WriteLine();
}
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.