visit(callback)
Iterates all cells (empty ones included) in row-major order and calls callback({ row, col, value }) for each. Reading and mutating the grid inside the callback is allowed.
Example
(click to randomly refill q with emojis)
Note
- All cells are visited in row-major order.
- The
callbackdecides what to do with each cell (e.g., refill with a random emoji).
Syntax
visit(callback)
Parameters
| Param | Description |
|---|---|
callback |
Function called for each visited cell, receiving an object { row, col, value }. Its return value is ignored |
What this page's examples use
- p5.quadrille
drawQuadrillecreateQuadrillecellLengthfillvisit- p5.js
createCanvasbackgroundrandom
Names the analysis can prove are called, and the line each one is documented on. Local variables and members of an unknown receiver are left out.