3.2. Loops
Overview of Letlang's looping mechanism
Letlang provides only one loop mechanism, the tailrec
function.
A tail recursive function returns either:
final[value]
to exit the looprecurse[args...]
to keep iterating with new argumentstailrec len<T>(items: list<T>, acc: int) -> int {
match items {
[] => final[acc],
[_ | tail] => recurse[tail, acc + 1],
};
}