Standard library modules for the minilang
language. Each .mil file is a module loaded with require.
This repository is shared as a git submodule of both:
minilang-compiler— the self-hosted toolchainminilang-boot— the handwritten C bootstrap toolchain
| Module | Provides |
|---|---|
builtin |
declarations for C-implemented native methods (sqrt, abs, time, clock_ms, getenv, cwrite, exit, csystem) |
math |
abs, min, max, clamp, pow, gcd, lcm, isEven, isOdd, factorial, fib, cos, sin, pi (trig in degrees, ×1000) |
string |
isEmpty, startsWith, endsWith, contains, repeat, countChar, reverse, split, lines, words, join, indexOf, replace, toUpper, toLower, … |
list |
range, copy, push, pop, first, last, insert, remove, slice, concat, reverse, sum, min, max, fill, swap, equal |
sort |
ints, intsDesc, strings, insert, bsearch, bsearchStr, isSorted |
json |
JSON parse/serialize using tagged pairs [type, payload] |
io |
read, write, append, exists, readLines, pathJoin, basename, dirname, ext, stem, withExt |
rand |
seed, next, int, range, chance, pick, shuffle (reproducible LCG) |
word |
example module showing nested require |
require math;
println toString(math.cos(60)); // 501
require sqrt from builtin; // C-native integer square root
println toString(sqrt(144)); // 12
The library code is licensed under GPL-3.0 (matching the minilang compiler).