Handbook
Glossary
update-grid ( gadget -- )
Vocabulary
game-of-life
Inputs
gadget
an
object
Outputs
None
Definition
USING:
accessors
kernel
math
math.order
sequences
sequences.private
;
IN:
game-of-life
::
update-grid
( gadget -- )
gadget
dim>>
first2
:>
( w h ) gadget
size>>
:>
size h w
[
size
/i
]
bi@
:>
( new-rows new-cols ) gadget
grid>>
:>
grid grid
grid-dim
:>
( rows cols ) rows new-rows
=
not
cols new-cols
=
not
or
[
new-rows new-cols
make-grid
:>
new-grid rows new-rows
min
<iota>
[|
j |
cols new-cols
min
<iota>
[|
i |
i j grid
nth-unsafe
nth-unsafe
i j new-grid
nth-unsafe
set-nth-unsafe
]
each
]
each
new-grid gadget
grid<<
]
when
;