mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-19 03:13:40 +00:00
... in some previously overlooked test cases.
tests/debugger/Mercury.options:
tests/debugger/Mmakefile:
tests/debugger/completion.completion_helper_1.m:
tests/debugger/completion.completion_helper_2.completion_helper_3.m:
tests/debugger/completion.completion_helper_2.m:
tests/debugger/completion.exp:
tests/debugger/completion.inp:
tests/debugger/completion.m:
Rename completion.sub1.m to completion.completion_helper_1.m,
rename completion.sub2.m to completion.completion_helper_2.m, and
rename completion.sub2.sub3.m to
completion.completion_helper_2.completion_helper_3.m.
tests/debugger/poly_io_retry_1.exp:
tests/debugger/poly_io_retry_1.inp:
tests/debugger/poly_io_retry_1.m:
tests/debugger/poly_io_retry_2.exp:
tests/debugger/poly_io_retry_2.inp:
tests/debugger/poly_io_retry_2.m:
Rename poly_io_retry/poly_io_retry2 to poly_io_retry_[12].
tests/debugger/shallow.exp:
tests/debugger/shallow.m:
tests/debugger/shallow_helper_1.m:
Rename shallow2.m to shallow_helper_1.m.
tests/debugger/user_event_1.exp:
tests/debugger/user_event_1.inp:
tests/debugger/user_event_1.m:
Rename user_event to user_event_1, due to the existence of user_event_2.
tests/general/Mmakefile:
tests/general/det_complicated_unify_1.exp:
tests/general/det_complicated_unify_1.m:
tests/general/det_complicated_unify_2.exp:
tests/general/det_complicated_unify_2.m:
Rename det_complicated_unify/det_complicated_unify2 to
det_complicated_unify_[12]. Note: only det_complicated_unify_1
is currently enabled.
tests/general/double_error_1.exp:
tests/general/double_error_1.m:
tests/general/double_error_2.exp:
tests/general/double_error_2.m:
Rename double_error/double_error2 as double_error_[12].
tests/general/liveness_1.exp:
tests/general/liveness_1.m:
tests/general/liveness_2.exp:
tests/general/liveness_2.m:
Rename liveness/liveness2 as liveness_[12].
tests/hard_coded/Mercury.options:
tests/hard_coded/Mmakefile:
tests/hard_coded/user_defined_equality_1.exp:
tests/hard_coded/user_defined_equality_1.m:
tests/hard_coded/user_defined_equality_2.exp:
tests/hard_coded/user_defined_equality_2.m:
Rename user_defined_equality/user_defined_equality2 as
user_defined_equality_[12].
tests/tabling/Mmakefile:
tests/tabling/expand_tuple_1.exp:
tests/tabling/expand_tuple_1.m:
tests/tabling/expand_tuple_2.exp:
tests/tabling/expand_tuple_2.m:
Rename expand_tuple/expand_tuple2 as expand_tuple_[12].
80 lines
1.7 KiB
Mathematica
80 lines
1.7 KiB
Mathematica
%---------------------------------------------------------------------------%
|
|
% vim: ts=4 sw=4 et ft=mercury
|
|
%---------------------------------------------------------------------------%
|
|
%
|
|
% The .exp file is for asm_fast.gc bootchecks without optimization.
|
|
% The .exp2 file is for asm_fast.gc bootchecks with -O5 --intermod-opt.
|
|
%
|
|
%---------------------------------------------------------------------------%
|
|
|
|
:- module shallow.
|
|
|
|
:- interface.
|
|
|
|
:- import_module io.
|
|
|
|
:- pred main(io::di, io::uo) is cc_multi.
|
|
|
|
:- implementation.
|
|
|
|
:- import_module list.
|
|
:- import_module int.
|
|
:- import_module shallow_helper_1.
|
|
|
|
main(!IO) :-
|
|
( if data(Data), queen(Data, Out) then
|
|
print_list(Out, !IO)
|
|
else
|
|
io.write_string("No solution\n", !IO)
|
|
).
|
|
|
|
:- pred data(list(int)::out) is det.
|
|
|
|
data([1, 2, 3, 4, 5]).
|
|
|
|
:- pred queen(list(int)::in, list(int)::out) is nondet.
|
|
|
|
queen(Data, Out) :-
|
|
qperm(Data, Out),
|
|
safe(Out).
|
|
|
|
:- pred qperm(list(T)::in, list(T)::out) is nondet.
|
|
|
|
qperm([], []).
|
|
qperm([X | Y], K) :-
|
|
qdelete(U, [X | Y], Z),
|
|
K = [U | V],
|
|
qperm(Z, V).
|
|
|
|
:- pred qdelete(T::out, list(T)::in, list(T)::out) is nondet.
|
|
|
|
qdelete(A, [A | L], L).
|
|
qdelete(X, [A | Z], [A | R]) :-
|
|
qdelete(X, Z, R).
|
|
|
|
:- pred print_list(list(int)::in, io::di, io::uo) is det.
|
|
|
|
print_list(Xs, !IO) :-
|
|
(
|
|
Xs = [],
|
|
io.write_string("[]\n", !IO)
|
|
;
|
|
Xs = [_ | _],
|
|
io.write_string("[", !IO),
|
|
print_list_2(Xs, !IO),
|
|
io.write_string("]\n", !IO)
|
|
).
|
|
|
|
:- pred print_list_2(list(int)::in, io::di, io::uo) is det.
|
|
|
|
print_list_2([], !IO).
|
|
print_list_2([X | Xs], !IO) :-
|
|
io.write_int(X, !IO),
|
|
(
|
|
Xs = []
|
|
;
|
|
Xs = [_ | _],
|
|
io.write_string(", ", !IO),
|
|
print_list_2(Xs, !IO)
|
|
).
|