5 / 5
Control Functions

Composition

When our flower gets more complicated, it is nice to keep things organized. Define your own functions to help indicate what the code does.

In this case: my_garden calls my_flower, which draws the 3 parts of the flower:

  • my_leaves: draws the 2 green leaves
  • my_stem: draws the stem with a wiggle
  • my_bud: draws the petals and bud

Besides helping organise, defining your own functions also allows for composition with the 4 control functions: repeat, ring, fork, and branch

Challenge!

  • Put my_flower inside fork like so: fork(my_flower)
  • Try out ring and repeat as well!
  • Go make your own beautiful creation! 🌷🌹🌻