Files
mercury/tests/dppd/contains_lam.m
Zoltan Somogyi 33eb3028f5 Clean up the tests in half the test directories.
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.
2015-02-14 20:14:03 +11:00

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