In This Chapter
Adding decision-making to your scripts
Using recursive functions
The scripts and functions you have created so far have all performed a series of tasks, in order, one at a time. However, sometimes it’s important to skip steps or to perform the same step more than once. Humans make decisions about what to do and how often to do it with ease, but computers need a little help. You must provide specific instructions as to when a decision is required and when to do something more than once.
As part of discovering how decisions are made and just how repetition works, you see two practical examples of how to employ your new skills. The first is a technique called recursion, which is simply a method of performing a task more than once, but in an elegant way. Using recursion makes solving some math problems significantly easier. The second involves the use of a menu. Most multifunction applications rely on menus to allow a user to select one option out of a number of possibilities.