Data update
This commit is contained in:
parent
4bb20c9b71
commit
cbaf4c4b64
12390 changed files with 318560 additions and 27248 deletions
28
Task/Mutual-recursion/Ada/mutual-recursion-1.adb
Normal file
28
Task/Mutual-recursion/Ada/mutual-recursion-1.adb
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
with Ada.Text_Io; use Ada.Text_Io;
|
||||
procedure Mutual_Recursion is
|
||||
function M(N : Integer) return Integer;
|
||||
function F(N : Integer) return Integer is
|
||||
begin
|
||||
if N = 0 then
|
||||
return 1;
|
||||
else
|
||||
return N - M(F(N - 1));
|
||||
end if;
|
||||
end F;
|
||||
function M(N : Integer) return Integer is
|
||||
begin
|
||||
if N = 0 then
|
||||
return 0;
|
||||
else
|
||||
return N - F(M(N-1));
|
||||
end if;
|
||||
end M;
|
||||
begin
|
||||
for I in 0..19 loop
|
||||
Put_Line(Integer'Image(F(I)));
|
||||
end loop;
|
||||
New_Line;
|
||||
for I in 0..19 loop
|
||||
Put_Line(Integer'Image(M(I)));
|
||||
end loop;
|
||||
end Mutual_recursion;
|
||||
20
Task/Mutual-recursion/Ada/mutual-recursion-2.adb
Normal file
20
Task/Mutual-recursion/Ada/mutual-recursion-2.adb
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
with Ada.Text_Io; use Ada.Text_Io;
|
||||
procedure Mutual_Recursion is
|
||||
function M(N: Natural) return Natural;
|
||||
function F(N: Natural) return Natural;
|
||||
|
||||
function M(N: Natural) return Natural is
|
||||
(if N = 0 then 0 else N – F(M(N–1)));
|
||||
|
||||
function F(N: Natural) return Natural is
|
||||
(if N =0 then 1 else N – M(F(N–1)));
|
||||
begin
|
||||
for I in 0..19 loop
|
||||
Put_Line(Integer'Image(F(I)));
|
||||
end loop;
|
||||
New_Line;
|
||||
for I in 0..19 loop
|
||||
Put_Line(Integer'Image(M(I)));
|
||||
end loop;
|
||||
|
||||
end Mutual_recursion;
|
||||
21
Task/Mutual-recursion/Euphoria/mutual-recursion.eu
Normal file
21
Task/Mutual-recursion/Euphoria/mutual-recursion.eu
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
integer idM, idF
|
||||
|
||||
function F(integer n)
|
||||
if n = 0 then
|
||||
return 1
|
||||
else
|
||||
return n - call_func(idM,{F(n-1)})
|
||||
end if
|
||||
end function
|
||||
|
||||
idF = routine_id("F")
|
||||
|
||||
function M(integer n)
|
||||
if n = 0 then
|
||||
return 0
|
||||
else
|
||||
return n - call_func(idF,{M(n-1)})
|
||||
end if
|
||||
end function
|
||||
|
||||
idM = routine_id("M")
|
||||
9
Task/Mutual-recursion/PowerShell/mutual-recursion.ps1
Normal file
9
Task/Mutual-recursion/PowerShell/mutual-recursion.ps1
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
function F($n) {
|
||||
if ($n -eq 0) { return 1 }
|
||||
return $n - (M (F ($n - 1)))
|
||||
}
|
||||
|
||||
function M($n) {
|
||||
if ($n -eq 0) { return 0 }
|
||||
return $n - (F (M ($n - 1)))
|
||||
}
|
||||
18
Task/Mutual-recursion/Rebol/mutual-recursion.rebol
Normal file
18
Task/Mutual-recursion/Rebol/mutual-recursion.rebol
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
Rebol [
|
||||
Title: "Mutual Recursion"
|
||||
URL: http://rosettacode.org/wiki/Mutual_Recursion
|
||||
References: [http://en.wikipedia.org/wiki/Hofstadter_sequence#Hofstadter_Female_and_Male_sequences]
|
||||
]
|
||||
|
||||
f: func [
|
||||
"Female."
|
||||
n [integer!] "Value."
|
||||
] [either 0 = n [1][n - m f n - 1]]
|
||||
|
||||
m: func [
|
||||
"Male."
|
||||
n [integer!] "Value."
|
||||
] [either 0 = n [0][n - f m n - 1]]
|
||||
|
||||
fs: [] ms: [] for i 0 19 1 [append fs f i append ms m i]
|
||||
print ["F:" mold fs crlf "M:" mold ms]
|
||||
Loading…
Add table
Add a link
Reference in a new issue