Function definition
Defining your own function.
Syntax
name :: Type -> Type\nname param = expression
Description
Functions are written as 'name parameter = expression'; a type signature (::) is placed above. Calls are without parentheses, and arguments are separated by spaces.
Example
Loading editor…
Expected output
17
When to use?
Preventing code repetition, breaking the program into parts.
Common mistakes
- ⚠️ Calls are without parentheses: addUp 8 9 (not addUp(8,9)).