Examples
The repository keeps single-file programs under examples/ and complete applications under examples/apps/. The gallery is being assembled; the source is available now.
Start with these
examples/hello.may— the smallest complete program.examples/strict.may— the strict typing features in one file.examples/features.may— closures, comprehensions, pattern matching and JSON.examples/may_otherwise.may— recoverable failures.examples/stdlib_tour.may— a tour of the standard library.examples/network/echo_server.mayandecho_client.may— TCP.
Applications
examples/apps/mayboard— a native UI board.examples/apps/maynes— an emulator with a test suite.examples/apps/maytasks— a task manager.
The build commands come from each project's may.json. For a single file:
mayc examples/hello.may -o /tmp/hello
/tmp/helloFor an application:
cd examples/apps/mayboard
may runA complete program
import "csv" as csv;
fun total(rows: List<Map<Str, Str>>) -> Int {
mut sum: Int = 0;
for row: Map<Str, Str> in rows {
sum += int(row["score"] ?? "0");
}
return sum;
}
let rows: List<List<Str>> = csv.csv_parse("name,score\nAda,10\nGrace,12\n");
let records: List<Map<Str, Str>> = csv.csv_records(["name", "score"], slice(rows, 1, len(rows)));
print(total(records));Output
22Every example in the finished gallery is compiled and run against the released compiler during the site build. Until a page says otherwise, check the repository version for the exact source.