-
One of the most important concepts of computer science,
-
is how to define new commands;
how to add your own words to the computer language.
-
Most computer languages have only about a hundred words or commands
-
and the art is to define your own new words out of these coding blocks.
-
We do this all the time at sports.
-
In basketball you learn how to dribble, how to do a lay-up and how to rebound.
-
Once you've learned these moves,
you learn new moves
-
and put together these building blocks,
like a pick and roll or give and go
-
and from there you can do more complex plays.
-
Once you learned that play and give it a name,
everybody on the team knows how to do it.
-
Simulary, once you learned a computer how to do an action once,
-
using these sequence of commands,
-
you can make up your own name for that action,
so it's easier to repeat it later.
-
When you define your own command and give it a name,
it's called a function.
-
If you are programming with blocks,
-
you can use functions if there is a set of actions
which you are gonna use a lot of times.
-
For example, you've written code to create a square,
-
You could define this as a function called "create a square".
-
Now you have a new block
that you can use multiple times to create multiple squares.
-
A lot of simple functions can be used,
to create more complex patterns.
-
In the next puzzle,
-
the code you recently wrote to make a circle
-
is available to you as a new function
that can make circles of different sizes.
-
Can you use it to help Elsa to create a new beautiful pattern in the snow?