mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-19 11:23:46 +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.
60 lines
1.4 KiB
Mathematica
60 lines
1.4 KiB
Mathematica
%---------------------------------------------------------------------------%
|
|
% vim: ts=4 sw=4 et ft=mercury
|
|
%---------------------------------------------------------------------------%
|
|
|
|
:- module lco_reorder.
|
|
:- interface.
|
|
|
|
:- import_module io.
|
|
|
|
:- pred main(io::di, io::uo) is det.
|
|
|
|
%---------------------------------------------------------------------------%
|
|
|
|
:- implementation.
|
|
|
|
:- import_module char.
|
|
:- import_module int.
|
|
:- import_module list.
|
|
|
|
%---------------------------------------------------------------------------%
|
|
|
|
main(!IO) :-
|
|
Cs = dup_literal(10000000),
|
|
io.write_string("length: ", !IO),
|
|
io.write_int(len(Cs, 0), !IO),
|
|
io.nl(!IO),
|
|
|
|
GTs = dup_ground_term(10000000),
|
|
io.write_string("length: ", !IO),
|
|
io.write_int(len(GTs, 0), !IO),
|
|
io.nl(!IO).
|
|
|
|
:- func dup_literal(int) = list(char).
|
|
|
|
dup_literal(N) = Xs :-
|
|
( N > 0 ->
|
|
Xs0 = dup_literal(N - 1),
|
|
% Previously the goal which constructs the literal would not be moved
|
|
% before the recursive goal.
|
|
Xs = ['A' | Xs0]
|
|
;
|
|
Xs = []
|
|
).
|
|
|
|
:- func dup_ground_term(int) = list(list(char)).
|
|
|
|
dup_ground_term(N) = Xs :-
|
|
( N > 0 ->
|
|
Xs0 = dup_ground_term(N - 1),
|
|
GT = ['A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A'],
|
|
Xs = [GT | Xs0]
|
|
;
|
|
Xs = []
|
|
).
|
|
|
|
:- func len(list(T), int) = int.
|
|
|
|
len([], N) = N.
|
|
len([_ | Xs], N) = len(Xs, N + 1).
|