Functions

Functions in Lumen are values, just like numbers and strings. Expressions that start with fn evaluate to functions:


    

Functions can be called by placing them first in a list expression. The list that appears after the name fn identifies the function's parameters:


    

Because functions are values, we can use variables to name them. The same rules apply when calling a function named by a variable:


    

The most common shortcut for defining functions is to use define and define-global in the following way:


    

A function's parameter list can contain both positional and key parameters, where the key's value is the name to bind:


    

Parameters in Lumen are always optional, and those without a supplied argument have the value nil.

Functions can also take a variable number of arguments by either specifying a single parameter instead of a list, or by using the rest key.