Examples
Here are some examples of Fungo code.
Summing Integers
We can write a function to sum a list of integers using a recursive
function. This function uses a match block to handle the anchor
case where the list is empty and the recursive case where the list is not empty.
In the recursive case, we destructure the list into the head and tail and add
the head to the result of the recursive call with the tail.
sum = func(n List<int>) int {
match n {
[] -> 0,
[head, ...tail] -> head + self(tail)
}
}
sum([1, 2, 3]) Minimum of a List
This function calculates the minimum of a list of integers. It uses a recursive function to iterate over the list and keep track of the current minimum.