Functions

Syntax:

<fn> ::= fn <ident> <generics>? (<params>?) <return-type> ? <block-expr>

<params> ::= <param> ( , <param> )* ,?

<param> ::= <expr> : <type>

<return-type> ::= -> <type>

Examples

fn identity<T>(t: T) -> T {
    t
}
fn naive_fib(n: number) -> number {
    if n < 2 { n } else { naive_fib(n-1) + naive_fib(n-2) }
}