Skip to content

Instantly share code, notes, and snippets.

@mwja
Last active April 9, 2017 17:37
Show Gist options
  • Save mwja/eb70aa7c1c7e1b7e0fe42ef62f93f9bc to your computer and use it in GitHub Desktop.
Save mwja/eb70aa7c1c7e1b7e0fe42ef62f93f9bc to your computer and use it in GitHub Desktop.
An example program in Otter, ruby extension for highlighting.
body :: [String, String] := [
"name" := "example",
"entry" := "Program.ot",
"includes" :: [String] := [
"Program.ot"
]
"out" := "program.exe"
]
Program :: class
Program.create :: Number := (args :: [Number := String])
j :: Number := 0 | j < args.len | j := j + 1 @
console.writeln: "\(j) : \(args[j])"
console.writeln: "press any key to exit..."
console.readkey
# with the arguments `a b c foo bar` and the filename `code.ot` it outputs
# 0 code.ot
# 1 a
# 2 b
# 3 c
# 4 foo
# 5 bar
public class Program
{
/// <summary>
/// The entry function.
/// </summary>
public static void Main(string[] args)
{
int j = 0;
while (j<args.Length)
{
System.Console.WriteLine(j.ToString() + " : " + args[j]);
j = j + 1;
}
System.Console.WriteLine("press any key to exit...");
System.Console.ReadKey();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment