function setup() en function draw()

I don’t understand the difference between function setup () and function draw ()

I read here on this forum → function setup ():
“This is where you get everything ready, load your pictures, etc. setup is like a
project manager, it gets things organised.”

“The draw function is the exciting one. Codea runs this 60 times per second,
and nothing gets on the screen unless draw puts it there. So this is really

Why can I place background(40,40,50) not under function setup()?
That’s not drawing, that’s loading… I think?

Setup runs first and only one time. This is a great place to setup variables and run any other code that you do not want being run 60 times a second.

Draw will run at best 60 times per second. It will redraw the screen each draw cycle. Placing a background here makes sure that the previous draw is erased and the new draw is drawn.

@AnnSophie why do you think backgroung() is loading? It is not loading anything, it is just drawing a uniform color big rectangle on the screen.
PS: welcome in Codea-land!

@AnnSophie, background() is drawing, not loading, and if you put it in setup, it will be overwritten in draw, 60 times a second as you mention.

If I understand it right
function draw() is a loop.
Can I program a sequence in codea?

It’s for children.
In other programlanguages (VBA, Java, …)
They learn first a sequence then variables with a sequence and then loops…

@AnnSophie - you should probably teach them variables, sequences and loops before trying to draw anything at all.

You can do all these things in the setup function, without the need to have a draw function.

Once they understand the basics of loops, if, etc, then they will be ready to do some drawing.

So for example, this code is all you need to show them how to increase a variable

function setup()
    for i=1,10 do