Escribe Antril, ejecútalo en tu navegador y compártelo con un enlace. Los programas se compilan a WebAssembly y se ejecutan en tu equipo, no en el servidor.
Ejecutar programas no está disponible en este momento: the WebAssembly linker (wasm-ld, part of LLVM) is not installed on this server. Aún puedes escribir, compartir y descargar código.
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();
}
Salida
Pulsa Ejecutar (o Ctrl+Enter) para compilar y ejecutar el programa.
Entrada
Lo que lee Console.ReadLine(), una línea a la vez.
Ctrl+Enter ejecuta. Tab agrega sangría (Shift+Tab la quita); pulsa Esc y luego Tab para salir del editor. Un programa puede ejecutarse durante 10 segundos.