Introducing Functions
In This Lesson, You Will Learn:
- What functions are and how they are constructed
- A few basic functions
- How function nesting works
Functions are pre-defined procedures that can be included as part of your expressions. Functions are used for a wide variety of tasks, primarily concerned with calculating, manipulating and summarising data.
Rather than writing out the entire function each time you want to use it, you instead write a small code snippet known as a function Call. The syntax of a function call consists of the function’s Identifier followed by parentheses containing zero or more Arguments.
Arguments are pieces of data, separated by commas, which are used within the function code in order to successfully execute the function. For example, we could imagine that a function named “Wash” would only need a single argument: the object you want to wash. In this case, the following could all be examples of valid function calls for Wash(x), where x is our function’s single argument:
- Wash(Face)
- Wash(Car)
- Wash(BehindYourEars)
Some functions do not require any arguments, and when called are represented solely by the function identifier followed by an empty pair of parentheses. An example of a real function with zero arguments is Rnd(), which simply returns a random number.
<< Previous: Lesson Summary | Next: Square or Round Brackets? >>