Hi!
I'm going to start every lecture with a promise and an artist to reference.
I promise that by the end of this lecture you'll be able understand how to use loops in your work to save you time and earth credits (aka money).
The first piece of work I saw of hers was
The Passing Winter", which is owned by the Tate. Go see it!
Earlier in my career I was lucky enough to collaborate on an installation inspired by that piece: The Hello Cube.
I think alot of Yayoi's work is about repetition, which is why she's perfect for today's lecture - which is on exactly that thing!
The main thing I want you keep in mind today is that iteration or looping or repeating is one of the most powerful tools for getting things done in coding. Loops let you repeat the same recipe or set of instructions or commands or block of code as many times as you like. You can set loops to run a set number of times, or for a certain period of time, or to run for every piece of information in a certain place (like for every entry in an address book) or even to run an interactive number of times (until the user presses a certain key for example).
By the end of this lecture, you'll know more about:
- Iteration - which is the obsfucatory term for repeating something several times
- Loops - another word for iteration and the term you'll here the most in coding
- The four different kinds of loops in p5.js
- A whole series of examples of looping in p5.js
- The concept of Scope in coding, and particularly in p5.js
Let's look at the definition of
Iteration - the
obsfucatory term for repeating something several times.
Loops are just a part of the wider coding world of
Control Flow. We've already encountered some control flow with if/else statements and switch statements. Another way of thinking about loops is doing things many times, but using logic to stop. Boolean logic in our case.
Let's venture further into the
p5.js tutorial on program (or control) flow, specifically the section on four different kinds of loops in p5.js. BTW - the structure of for loops is going to take a bit of time to get used to - before you know it you'll be typing them out automatically!