Kaiper has functions, which are invocable objects.
Named and anonymous functions with bodies:
def [name](parameters...) = expression def [name](parameters...) { statements }
Implicit and lambda functions:
def { parameters... -> statements } def _ + _
Examples:
def add(x, y) = x + y def fib(x) { if x <= 1 { return x } return fib(x - 1) + fib(x - 2) }
They are first class objects, which means they can be passed as parameters to other functions.
[1,2,3,4,5] |> Array.reduce 0, add
There was an error while loading. Please reload this page.