Examples

Callables

Functions and lambdas as values. Borrow one to use it twice.

main (print)

# (int -> int) is a callable. A named function or a lambda fits it.
# A callable is a value that moves; borrow it (&) to use it twice.
twice(f &(int -> int), x int) int
    f(f(x))

inc(x int) int
    x + 1

main()
    offset = 10
    addOffset = (x int: x + offset)
    a = twice(inc, 1)
    b = twice(addOffset, 1)
    print.line("{a} {b}")
3 21