Data update
This commit is contained in:
parent
8e4e15fa56
commit
72eb4943cb
1853 changed files with 35514 additions and 9441 deletions
11
Task/Mutual-recursion/Miranda/mutual-recursion.miranda
Normal file
11
Task/Mutual-recursion/Miranda/mutual-recursion.miranda
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
main :: [sys_message]
|
||||
main = [Stdout ("F: " ++ show (map f [0..20]) ++ "\n"),
|
||||
Stdout ("M: " ++ show (map m [0..20]) ++ "\n")]
|
||||
|
||||
f :: num->num
|
||||
f 0 = 1
|
||||
f n = n - m (f (n-1))
|
||||
|
||||
m :: num->num
|
||||
m 0 = 0
|
||||
m n = n - f (m (n-1))
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
##
|
||||
function M(n: integer): integer; forward;
|
||||
function F(n: integer): integer := n < 1 ? 1 : n - M(F(n - 1));
|
||||
function M(n: integer): integer := n < 1 ? 0 : n - F(M(n - 1));
|
||||
function F(n: integer): integer := if n < 1 then 1 else n - M(F(n - 1));
|
||||
function M(n: integer): integer := if n < 1 then 0 else n - F(M(n - 1));
|
||||
|
||||
(0..19).select(x -> F(x)).println;
|
||||
(0..19).select(x -> M(x)).println;
|
||||
|
|
|
|||
15
Task/Mutual-recursion/Zig/mutual-recursion.zig
Normal file
15
Task/Mutual-recursion/Zig/mutual-recursion.zig
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
fn f(n: u64) u64 {
|
||||
return if (n == 0) 1 else n-m(f(n-1));
|
||||
}
|
||||
|
||||
fn m(n: u64) u64 {
|
||||
return if (n == 0) 0 else n-f(m(n-1));
|
||||
}
|
||||
|
||||
pub fn main() !void {
|
||||
const stdout = @import("std").io.getStdOut().writer();
|
||||
try stdout.writeAll(" n F M\n");
|
||||
for (0..20) |n| {
|
||||
try stdout.print("{d: >2}: {d: >2} {d: >2}\n", .{n, f(n), m(n)});
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue