mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-15 01:13:30 +00:00
tests/accumulator/*.m:
tests/analysis_*/*.m:
tests/benchmarks*/*.m:
tests/debugger*/*.{m,exp,inp}:
tests/declarative_debugger*/*.{m,exp,inp}:
tests/dppd*/*.m:
tests/exceptions*/*.m:
tests/general*/*.m:
tests/grade_subdirs*/*.m:
tests/hard_coded*/*.m:
Make these tests use four-space indentation, and ensure that
each module is imported on its own line. (I intend to use the latter
to figure out which subdirectories' tests can be executed in parallel.)
These changes usually move code to different lines. For the debugger tests,
specify the new line numbers in .inp files and expect them in .exp files.
59 lines
1.9 KiB
Mathematica
59 lines
1.9 KiB
Mathematica
%---------------------------------------------------------------------------%
|
|
% vim: ts=4 sw=4 et ft=mercury
|
|
%---------------------------------------------------------------------------%
|
|
%
|
|
% The "depth" Benchmark.
|
|
% Part of the DPPD Library.
|
|
%
|
|
% A Lam & Kusalik benchmark. It consists of a simple non-ground
|
|
% meta-interpreter which has to be specialised for a fully-unfoldable
|
|
% object program. It uses neither negations nor built-ins. For a
|
|
% slightly different and more intricate example see the ex_depth
|
|
% benchmark (which is not fully unfoldable).
|
|
|
|
depth(rue, 0).
|
|
depth((_g1, _gs), _depth) :-
|
|
depth(_g1, _depth_g1),
|
|
depth(_gs, _depth_gs),
|
|
max(_depth_g1, _depth_gs, _depth).
|
|
depth(_goal, s(_depth)) :-
|
|
prog_clause(_goal, _body),
|
|
depth(_body, _depth).
|
|
|
|
max(_num, 0, _num).
|
|
max(0, s(_num), s(_num)).
|
|
max(s(_x), s(_y), s(_max)) :-
|
|
max(_x, _y, _max).
|
|
|
|
prog_clause(member(_X, _Xs), append(_, [_X | _], _Xs)).
|
|
prog_clause(append([], _L, _L), true).
|
|
prog_clause(append([_X | _L1], _L2, [_X | _L3]), append(_L1, _L2, _L3)).
|
|
|
|
% The partial deduction query
|
|
%
|
|
% :- depth(member(X, [a, b, c, m, d, e, m, f, g, m, i, j]), Depth).
|
|
%
|
|
% The run-time queries
|
|
%
|
|
% :- depth(member(i, [a, b, c, m, d, e, m, f, g, m, i, j]), Depth).
|
|
%
|
|
% Example solution
|
|
%
|
|
% This benchmark can be fully unfolded. With the ECCE partial deduction
|
|
% system one can obtain the following:
|
|
|
|
depth__1(a, s(s(0))).
|
|
depth__1(b, s(s(s(0)))).
|
|
depth__1(c, s(s(s(s(0))))).
|
|
depth__1(m, s(s(s(s(s(0)))))).
|
|
depth__1(d, s(s(s(s(s(s(0))))))).
|
|
depth__1(e, s(s(s(s(s(s(s(0)))))))).
|
|
depth__1(m, s(s(s(s(s(s(s(s(0))))))))).
|
|
depth__1(f, s(s(s(s(s(s(s(s(s(0)))))))))).
|
|
depth__1(g, s(s(s(s(s(s(s(s(s(s(0))))))))))).
|
|
depth__1(m, s(s(s(s(s(s(s(s(s(s(s(0)))))))))))).
|
|
depth__1(i, s(s(s(s(s(s(s(s(s(s(s(s(0))))))))))))).
|
|
depth__1(j, s(s(s(s(s(s(s(s(s(s(s(s(s(0)))))))))))))).
|
|
|
|
% Michael Leuschel / K.U. Leuven / michael@cs.kuleuven.ac.be
|