A-M baby
This commit is contained in:
parent
764da6cbbb
commit
db842d013d
19005 changed files with 197040 additions and 7 deletions
11
Task/Mutual-recursion/REXX/mutual-recursion-1.rexx
Normal file
11
Task/Mutual-recursion/REXX/mutual-recursion-1.rexx
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
/*REXX program shows mutual recursion (via Hofstadter Male & Female seq)*/
|
||||
arg lim .; if lim=='' then lim=40; pad=left('',20)
|
||||
|
||||
do j=0 to lim; jj=Jw(j); ff=F(j); mm=M(j)
|
||||
say pad 'F('jj") =" Jw(ff) pad 'M('jj") =" Jw(mm)
|
||||
end /*j*/
|
||||
exit /*stick a fork in it, we're done.*/
|
||||
/*─────────────────────────────────────F, M, Jw subroutines────────────*/
|
||||
F: procedure; arg n; if n==0 then return 1; return n-M(F(n-1))
|
||||
M: procedure; arg n; if n==0 then return 0; return n-F(M(n-1))
|
||||
Jw: return right(arg(1),length(lim)) /*right justifies # for nice look*/
|
||||
14
Task/Mutual-recursion/REXX/mutual-recursion-2.rexx
Normal file
14
Task/Mutual-recursion/REXX/mutual-recursion-2.rexx
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
/*REXX program shows mutual recursion (via Hofstadter Male & Female seq)*/
|
||||
arg lim .;if lim=='' then lim=99; hm.=; hm.0=0; hf.=; hf.0=1; Js=; Fs=; Ms=
|
||||
|
||||
do j=0 to lim; ff=F(j); mm=M(j)
|
||||
Js=Js jW(j); Fs=Fs jw(ff); Ms=Ms jW(mm)
|
||||
end /*j*/
|
||||
say 'Js=' Js
|
||||
say 'Fs=' Fs
|
||||
say 'Ms=' Ms
|
||||
exit /*stick a fork in it, we're done.*/
|
||||
/*─────────────────────────────────────F, M, Jw subroutines────────────*/
|
||||
F: procedure expose hm. hf.; arg n; if hf.n=='' then hf.n=n-M(F(n-1)); return hf.n
|
||||
M: procedure expose hm. hf.; arg n; if hm.n=='' then hm.n=n-F(M(n-1)); return hm.n
|
||||
Jw: return right(arg(1),length(lim)) /*right justifies # for nice look*/
|
||||
18
Task/Mutual-recursion/REXX/mutual-recursion-3.rexx
Normal file
18
Task/Mutual-recursion/REXX/mutual-recursion-3.rexx
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
/*REXX program shows mutual recursion (via Hofstadter Male & Female seq)*/
|
||||
/*If LIM is negative, only show a single result for the abs(lim) entry.*/
|
||||
|
||||
parse arg lim .; if lim=='' then lim=99; aLim=abs(lim)
|
||||
parse var lim . hm. hf. Js Fs Ms; hm.0=0; hf.0=1
|
||||
|
||||
do j=0 to Alim; ff=F(j); mm=M(j)
|
||||
Js=Js jW(j); Fs=Fs jw(ff); Ms=Ms jW(mm)
|
||||
end
|
||||
|
||||
if lim>0 then say 'Js=' Js; else say 'J('aLim")=" word(Js,aLim+1)
|
||||
if lim>0 then say 'Fs=' Fs; else say 'F('aLim")=" word(Fs,aLim+1)
|
||||
if lim>0 then say 'Ms=' Ms; else say 'M('aLim")=" word(Ms,aLim+1)
|
||||
exit /*stick a fork in it, we're done.*/
|
||||
/*─────────────────────────────────────F, M, Jw subroutines────────────*/
|
||||
F: procedure expose hm. hf.; arg n; if hf.n=='' then hf.n=n-M(F(n-1)); return hf.n
|
||||
M: procedure expose hm. hf.; arg n; if hm.n=='' then hm.n=n-F(M(n-1)); return hm.n
|
||||
Jw: return right(arg(1),length(lim)) /*right justifies # for nice look*/
|
||||
Loading…
Add table
Add a link
Reference in a new issue