The Iterator
Traversing the infinite dimensions of an arcane array without knowing its bounds.
✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Iterator
ARCANUM SCHOOL: Divination // Dimensional Traversal
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// CODEX INCANTATION //
NB. In J, iteration is usually implicit via rank (" or S:)
matrix =: 3 3 $ 1 2 3 4 5 6 7 8 9
NB. Iterate over rows (rank 1)
process_row =: 3 : '''Row sum: '' , ": +/ y'
NB. The rank conjunction (") acts as the iterator
iterate =: process_row"1
NB. Usage: iterate matrix
Implicit iteration through rank (") is the idiomatic J equivalent of the Iterator pattern.
Runic Tags:
#iterator
#rank
#implicit
#dimensions