Core language
Functions and calls
Define functions with let, call them normally, and use let rec for recursion.
What
Functions are values you can bind, pass, and call.
Why
This gives a direct way to organize repeated logic without relying on special syntax blocks.
How
Call named functions like usual value calls, then define recursion in the same surface with let rec.
Compare
static int twice(int x) {
return x + x;
}
int answer = twice(21);let twice (x : Int) : Int := x + x;
twice(21);fn twice(x: i32) -> i32 {
x + x
}
let answer = twice(21);function twice(x: number): number {
return x + x;
}
const answer = twice(21);let rec loop (x : Int) : Int :=
case x of (
| 0 => 0
| _ => loop(x - 1)
);When
Use recursion for traversals, accumulations, and simple parsers when a loop is not needed.
Analogy
Like defining a helper in Python and calling itself from its own body, but in one value-binding style.
Try it
Bind and call a function, then add the recursive form and continue to Imports and packages.
github.com/musi-lang/musi
musi-lang.com