KRL supports functions as first-class objects. KRL supports only anonymous functions, but they can be given names by binding them to a variable in a declaration. Here's an example:
...
Functions are declared using the keyword function
followed by a possibly empty, parentheses-delimited, comma-separated list of parameters and a block of code.
The parameters are a possibly empty, comma-separated list of variable names. All parameters can be assigned a default value. More details can be found in Using Optional and Named Parameters.
The code block of the function is delimited by curly braces and contains a list of semicolon-separated declarations and a single expression. The declarations are optional, but every function code block must end with an expression. The value of the final expression is the return value of the function.
...