Mutual recursion: Difference between revisions

Content added Content deleted
(→‎{{header|Tailspin}}: function can now forward-reference)
m (→‎with memoization, specific entry: optimized the 1st DO loop, it's over a magnitude faster.)
Line 2,893: Line 2,893:
w= length(aLim); $m.=.; $m.0= 0; $f.=.; $f.0= 1; Js=; Fs=; Ms=
w= length(aLim); $m.=.; $m.0= 0; $f.=.; $f.0= 1; Js=; Fs=; Ms=


do j=0 for Alim+1
do j=0 for aLim+1; call F(J); call M(j)
Js= Js right(j, w); Fs= Fs right( F(j), w); Ms= Ms right( M(j), w)
if lim<0 then iterate
Js= Js right(j, w); Fs= Fs right($f.j, w); Ms= Ms right($m.j, w)
end /*j*/
end /*j*/


if lim>0 then say 'Js=' Js; else say 'J('aLim")=" word(Js, aLim+1)
if lim>0 then say 'Js=' Js; else say 'J('aLim")=" right( aLim, w)
if lim>0 then say 'Fs=' Fs; else say 'F('aLim")=" word(Fs, aLim+1)
if lim>0 then say 'Fs=' Fs; else say 'F('aLim")=" right($f.aLim, w)
if lim>0 then say 'Ms=' Ms; else say 'M('aLim")=" word(Ms, aLim+1)
if lim>0 then say 'Ms=' Ms; else say 'M('aLim")=" right($m.aLIM, w)
exit /*stick a fork in it, we're all done. */
exit /*stick a fork in it, we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
/*──────────────────────────────────────────────────────────────────────────────────────*/