Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
7
Task/Mutual-recursion/Picat/mutual-recursion-1.picat
Normal file
7
Task/Mutual-recursion/Picat/mutual-recursion-1.picat
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
table
|
||||
f(0) = 1.
|
||||
f(N) = N - m(f(N-1)), N > 0 => true.
|
||||
|
||||
table
|
||||
m(0) = 0.
|
||||
m(N) = N - f(m(N-1)), N > 0 => true.
|
||||
17
Task/Mutual-recursion/Picat/mutual-recursion-2.picat
Normal file
17
Task/Mutual-recursion/Picat/mutual-recursion-2.picat
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
table
|
||||
female(0,1).
|
||||
female(N,F) :-
|
||||
N>0,
|
||||
N1 = N-1,
|
||||
female(N1,R),
|
||||
male(R, R1),
|
||||
F = N-R1.
|
||||
|
||||
table
|
||||
male(0,0).
|
||||
male(N,F) :-
|
||||
N>0,
|
||||
N1 = N-1,
|
||||
male(N1,R),
|
||||
female(R, R1),
|
||||
F = N-R1.
|
||||
20
Task/Mutual-recursion/Picat/mutual-recursion-3.picat
Normal file
20
Task/Mutual-recursion/Picat/mutual-recursion-3.picat
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
go =>
|
||||
N = 30,
|
||||
println(func),
|
||||
test_func(N),
|
||||
println(pred),
|
||||
test_pred(N),
|
||||
nl.
|
||||
nl.
|
||||
|
||||
% Testing the function based approach
|
||||
test_func(N) =>
|
||||
println([M : I in 0..N, male(I,M)]),
|
||||
println([F : I in 0..N, female(I,F)]),
|
||||
nl.
|
||||
|
||||
% Testing the predicate approach
|
||||
test_pred(N) =>
|
||||
println([M : I in 0..N, male(I,M)]),
|
||||
println([F : I in 0..N, female(I,F)]),
|
||||
nl.
|
||||
Loading…
Add table
Add a link
Reference in a new issue