5 / 5Control 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 leavesmy_stem
: draws the stem with a wigglemy_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
insidefork
like so:fork(my_flower)
- Try out
ring
andrepeat
as well! - Go make your own beautiful creation! 🌷🌹🌻