Vocabulary
game-of-life

Inputs
gadgetan object


Outputs
None

Definition


:: 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 nth i j new-grid nth set-nth ]
each
] each new-grid gadget grid<<
] when ;