Apply a callback to an array: Difference between revisions

m
→‎{{header|REXX}}: added DO-END labels, added comments, added whitespace. -- ~~~~
m (→‎{{header|REXX}}: added DO-END labels, added comments, added whitespace. -- ~~~~)
Line 1,517:
 
=={{header|REXX}}==
<lang rexx>/*REXX program to apply a callback to ana stemmed (REXX) array. */
a.=; b.=
a.0= 0
Line 1,534:
call bangit 'a','b' /*factorialize the A array, store results in B */
call listab ' after'
exit /*stick a fork in it, we're done.*/
exit
/*──────────────────────────────────BANGIT subroutine───────────────────*/
/*─────────────────────────────────────BANGIT subroutine────────────────*/
bangit: do ji=0
_=value(arg(1)'.'ji); if _=='' then return
call value arg(2)'.'ji,fact(_)
end /*i*/
/*──────────────────────────────────FACT subroutine─────────────────────*/
/*─────────────────────────────────────FACT subroutine──────────────────*/
fact: procedure; !=1; do j=2 to arg(1); !=!*j; end; return !
/*──────────────────────────────────LISTAB subroutine───────────────────*/
/*─────────────────────────────────────LISTAB subroutine────────────────*/
listab: do j=0 while a.j\==''; say arg(1) 'a.'j"="a.j; end /*j*/
say; do k=0 while b.k\==''; say arg(1) 'ab.'jk"="ab.jk; end /*k*/
end
say
do j=0 while b.j\==''
say arg(1) 'b.'j"="b.j
end
return</lang>
'''output'''