Files
mercury/tests/dppd/upto_sum1.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

51 lines
1.2 KiB
Mathematica

%---------------------------------------------------------------------------%
% vim: ts=4 sw=4 et ft=mercury
%---------------------------------------------------------------------------%
%
% The "upto.sum1" Benchmark.
% Part of the DPPD Library.
%
% This is a sophisticated deforestation example coming from the
% functional programming community. It was handed over to me by Jesper
% Jorgensen, who adapted it from Wadler's paper Deforestation:
% Transforming programs to eliminate intermediate trees in TCS,
% 73:231-248, 1990. The program calculates the sum of squares for 1 up to n.
:- module upto_sum1.
:- interface.
:- pred upto_sum1 is semidet.
:- implementation.
:- import_module run.
:- import_module upto_sum_impl.
upto_sum1 :-
sumsquaresupto(5, X1),
use(X1),
sumsquaresupto(15, X2),
use(X2),
sumsquaresupto(25, X3),
use(X3),
sumsquaresupto(30, X4),
use(X4).
% The partial deduction query
%
% :- sumsquaresupto(N, S).
%
% The run-time queries
%
% :- sumsquaresupto(5, X).
% :- sumsquaresupto(15, X).
% :- sumsquaresupto(25, X).
% :- sumsquaresupto(30, X).
%
% Example solution
%
% to be inserted
%
% Michael Leuschel / K.U. Leuven / michael@cs.kuleuven.ac.be