Menu
Home Page

ICT

Calling Functions

 

LC: To call functions from other functions

 

Last week we looked at decomposition, this is the process of breaking a larger problem into smaller pieces.

 

Once you have managed to break down the problem you can now combine your functions to solve the bigger problem, this is called composition.

 

 

 

We broke the above problem into 2 separate functions.

 

A function to turn around and a function to solve the stairs.

 

Look at the solution below, can you see how the function to turn around has been nested inside the solve the stairs function?

 

 

Look at the problem below, using composition can you tweak the code inside the function solveRow() so that it solves a bigger part of the puzzle?

 

 

Now have a try for yourself, remember to check if there are any items that need finishing first before moving onto the next activity.

Top