 |
YAP 7.1.0
|
4ds(
X,
Y,
Z)
:- Y is 2*X,
Z is X*X.
6double(
X,
Y)
:- Y is 2*X.
8square(
X,
Y)
:- Y is X*X.
10plus2(
X,
Y,
Z,
A)
:- A is X+Y+Z.
12t1(
X,
Y)
:- mapargs(double,
X,
Y).
14mapargs
:- t1(a(
1,
2,
3,
4,
5),
S),
writeln(
S).
16t2(
G,
X,
Y)
:- mapargs(
G,
X,
Y).
18mapargs
:- t2(double, a(
1,
2,
3,
4,
5),
S),
writeln(
S).
21t3(
X,
Y,
Z)
:- mapargs(ds,
X,
Y,
Z).
23mapargs
:- t3(a(
1,
2,
3,
4,
5),
S,
T),
writeln(
S:T).
26t4(
G,
X,
Y,
Z)
:- mapargs(
G,
X,
Y,
Z).
28mapargs
:- t4(ds, a(
1,
2,
3,
4,
5),
S,
T),
writeln(
S:T).
30t5(
X)
:- mapargs(integer,
X).
32mapargs
:- t5(a(
1,
2,
3,
4,
5)),
writeln(ok).
34t6(
G,
X)
:- mapargs(
G,
X).
36mapargs
:- t6(integer, a(
1,
2,
3,
4,
5)),
writeln(ok).
38t7(
X,
S)
:- foldargs(plus,
X,
0,
S).
40foldargs
:- t7(a(
1,
2,
3,
4,
5),
S),
writeln(
S).
42t8(
G,
X,
S)
:- foldargs(
G,
X,
0,
S).
44foldargs
:- t8(plus, a(
1,
2,
3,
4,
5),
S),
writeln(
S).
47t9(
X,
Y,
S)
:- foldargs(plus2,
X,
Y,
0,
S).
49foldargs
:- t9(a(
1,
2,
3,
4,
5), a(
1,
2,
3,
4,
5),
S),
writeln(
S).
51t10(
G,
X,
Y,
S)
:- foldargs(
G,
X,
Y,
0,
S).
53foldargs
:- t10(plus2, a(
1,
2,
3,
4,
5), a(
1,
2,
3,
4,
5),
S),
writeln(
S).