mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-24 05:43:53 +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.
56 lines
1.6 KiB
Mathematica
56 lines
1.6 KiB
Mathematica
%---------------------------------------------------------------------------%
|
|
% vim: ts=4 sw=4 et ft=mercury
|
|
%---------------------------------------------------------------------------%
|
|
%
|
|
% The "contains" Benchmark.
|
|
% Part of the DPPD Library.
|
|
%
|
|
% This is the contains example from the Lam & Kusalik benchmarks. It is
|
|
% a string matcher which tries to be somewhat clever, but is highly
|
|
% non-deterministic and in the end not very efficient at all. This
|
|
% benchmark program uses the \== builtin.
|
|
|
|
:- module contains_lam.
|
|
|
|
:- interface.
|
|
|
|
:- pred contains_lam is semidet.
|
|
|
|
:- implementation.
|
|
|
|
:- import_module contains.
|
|
:- import_module list.
|
|
|
|
contains_lam :-
|
|
contains_aab([a, b, c, d, e, f, g, h, a, a, b,
|
|
i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z]).
|
|
|
|
% The partial deduction query
|
|
%
|
|
% :- contains([a, a, b], X).
|
|
%
|
|
% The run-time queries
|
|
%
|
|
% :- contains([a, a, b], [a, b, c, d, e, f, g, h, a, a, b,
|
|
% i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z]).
|
|
%
|
|
% Example solution
|
|
%
|
|
% The following specialised program can be obtained by the ECCE partial
|
|
% deduction system. It runs more than 10 times faster than the original.
|
|
%
|
|
% contains__1([X1 | X2]) :- con__2(X1, X2).
|
|
%
|
|
% con__2(a, [X1 | X2]) :- con__3(X1, X2).
|
|
% con__2(X1, [X2 | X3]) :- X1 \= a, con__2(X2, X3).
|
|
%
|
|
% con__3(a, [X1 | X2]) :- con__4(X1, X2).
|
|
% con__3(X1, [X2 | X3]) :- X1 \= a, con__2(X2, X3).
|
|
%
|
|
% con__4(b, X1).
|
|
% con__4(X1, [X2 | X3]) :- X1 \= b, con__2(X2, X3).
|
|
% con__4(a, [X1 | X2]) :- con__3(X1, X2).
|
|
% con__4(a, [X1 | X2]) :- con__4(X1, X2).
|
|
%
|
|
% Michael Leuschel / K.U. Leuven / michael@cs.kuleuven.ac.be
|