Learn Programming - ZedLX

A Free Computer Programming Tutorial for Beginners

Functions [1/9]


User-defined functions are created by the keyword fn.

The given program defines a function named triple. The function triple has one parameter, which is named a and it is of type num.

The function triple is called three times in this program. Each function call causes the function to be executed.

The execution of function triple produces a return value. The return value of a function is given after the two colon symbols (::). The return value of function triple is equal to the result of expression a*3.

The type of return value is given after the keyword fn and before the function name. The type of return value is num.

Functions are a crucial aspect of programming languages. Functions describe computations.