Anonymous user
Loops/Foreach: Difference between revisions
→FOREACH
Line 1,274:
cells bounds do i @ . cell +loop ; \ 3 2 1</lang>
===FOREACH===
<lang forth>: FOREACH ( array size XT --)
>R \ save execution token on return stack
CELLS BOUNDS \ covert addr len -> last first addresses
Line 1,287:
CELL+ \ move first to the next memory cell
REPEAT
R> DROP \ clean return stack
2DROP \ and data stack
;
Line 1,297:
\ Usage example:
A[] 10 ' ? FOREACH </lang>
=={{header|Fortran}}==
|