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)

edit, then run

Note

  • All cells are visited in row-major order.
  • The callback decides 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
drawQuadrille createQuadrille cellLength fill visit
p5.js
createCanvas background random

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.