Exercise 10: Filling the blanks

Filling the blanks

Let's understand what we've just done The first thing we did was to declare a procedure, but with a little difference: it takes a parameter, called “color”.

procedure Drop3(color) {
  Drop(color)
  Drop(color)
  Drop(color)
}

Parameters (those names between brackets) are special, since they are replaced by real values when we invoke them. For example, if they are invoked like this…

program {
  Drop3(Black)
}

…what is executed is:

Drop(Black)
Drop(Black)
Drop(Black)

And if they are invoked like this…

program {
  Drop3(Red)
}

…what is executed is

Drop(Red)
Drop(Red)
Drop(Red)

Note that every time “color” appears, it is replaced by the value written in the invoking.

Let's see what can be done so far: write a program which drops three green stones using the procedure Drop3.

You must sign in before submitting your solutions

Oops, your solution didn't work

  • Check that your program does not have recursion or an infinite loop
  • Check that you have an internet connection
  • Wait a while and try again

We are processing you solution

Please press F5 if results are not displayed after a few seconds