:- use_module(maplist). :- use_module(lambda_sicstus). xplus(X, Y, Z) :- Z is X+Y. numlist(1, N, L) :- length(L, N), numbered_from(L, 1). numbered_from([], _). numbered_from([N0|Ns], N0) :- N1 is N0+1, numbered_from(Ns, N1). xsum(L, Q) :- maplist(xplus(1),L,Q). sum(L, L2) :- maplist(plus(1), L, L2). add1([], []). add1([H0|T0], [H|T]) :- H is H0 + 1, add1(T0, T). t :- t(1000). t(N) :- numlist(1, 1000, L), \+ \+time(forall(between(1, N, _), sum(L, _))), \+ \+time(forall(between(1, N, _), add1(L, _))), \+ \+time(forall(between(1, N, _), maplist(\X^Y^(Y is X+1), L, _))), \+ \+time(forall(between(1, N, _), xsum(L, _))), \+ \+time(forall(between(1, N, _), maplist(\X^Y^plus(X,1,Y), L, _))), \+ \+time(forall(between(1, N, _), maplist(\X^plus(X,1), L, _))), write(----------), nl, \+ \+time(forall(between(1, N, _), sum(L, _))), \+ \+time(forall(between(1, N, _), add1(L, _))), \+ \+time(forall(between(1, N, _), maplist(\X^Y^(Y is X+1), L, _))), \+ \+time(forall(between(1, N, _), xsum(L, _))), \+ \+time(forall(between(1, N, _), maplist(\X^Y^plus(X,1,Y), L, _))), \+ \+time(forall(between(1, N, _), maplist(\X^plus(X,1), L, _))).