A block is a list of commands that are executed in the order they appear:
[COMMAND1 COMMAND2 COMMAND3 ... ]
Blocks appear in many contexts:
ask AGENTS [COMMAND1 COMMAND2 COMMAND3 ... ]
hatch N [COMMAND1 COMMAND2 COMMAND3 ... ]
if CONDITION [COMMAND1 COMMAND2 COMMAND3 ... ]
while [CONDITION] [COMMAND1 COMMAND2 COMMAND3 ... ]
We may also consider the body of a procedure or reporter to be a block:
to do-something
COMMAND1 COMMAND2 COMMAND3 ...
end
Blocks can be nested inside of blocks. Things can get complicated. For example:
ask turtle 0
[
ask turtle 5
[
draw-square
ask turtle 3
[
draw-circle
]
draw-hexagon
]
draw-triangle
]
To keep things straight, we need to understand the asking stack.