mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-30 08:44:37 +00:00
Estimated hours taken: 0.1 Branches: main Delete the obsolete versions of the all-solutions predicates from std_util.m. (Normally we would wait until after the 0.13 release, but we don't want them in the next g12 release of Mercury which is why they are being deleted now.) Document some parts of the library that are handled as special cases by the compiler and the declarative debugger. library/std_util.m: Delete the obsolete versions of the all-solutions predicates from this module. library/solutions.m: Mention that these predicates are handled as a special case in browser/declarative_tree.m: Reformat a descriptive comment so that the library reference manual doesn't have a line that exceeds 80 characters in length. library/builtin.m: Mention that cc_multi_equal is handled as a special case in browser/declarative_tree.m. Mention that dynamic_cast/2 is handled as a special case in compiler/const_prop.m. tests/*/*.m: Import solutions where necessary.
129 lines
2.2 KiB
Mathematica
129 lines
2.2 KiB
Mathematica
% This test case is a copy of tests/general/complex_failure, and tests
|
|
% whether this test case can be compiled with --use-trail; this caused
|
|
% a compiler abort with the 21 September, 1998 version of the compiler.
|
|
%
|
|
% Unfortunately, we cannot just specify --use-trail for complex_failure
|
|
% in tests/general, since that would cause a link error in the usual case
|
|
% that the runtime being linked with is not in a trailing grade.
|
|
|
|
:- module complex_failure.
|
|
|
|
:- interface.
|
|
|
|
:- import_module io.
|
|
|
|
:- pred main(io__state::di, io__state::uo) is det.
|
|
|
|
:- implementation.
|
|
|
|
:- import_module solutions, list, int.
|
|
|
|
main -->
|
|
{ solutions(p1, Xs1) },
|
|
print_list(Xs1),
|
|
{ solutions(p2, Xs2) },
|
|
print_list(Xs2),
|
|
{ solutions(p3, Xs3) },
|
|
print_list(Xs3).
|
|
|
|
:- pred p1(int::out) is nondet.
|
|
|
|
p1(X) :-
|
|
p(1, X).
|
|
|
|
:- pred p2(int::out) is nondet.
|
|
|
|
p2(X) :-
|
|
p(2, X).
|
|
|
|
:- pred p3(int::out) is nondet.
|
|
|
|
p3(X) :-
|
|
p(3, X).
|
|
|
|
:- pred p(int::in, int::out) is nondet.
|
|
|
|
p(A, X) :-
|
|
% The first if-then-else can hijack the redoip/redofr slots
|
|
% of p's frame.
|
|
( if
|
|
some [B] ( q(A, B) ; r(A, B) )
|
|
then
|
|
C = B * 10
|
|
% s(B, C)
|
|
else
|
|
C = A * 10
|
|
% s(A, C)
|
|
),
|
|
% The second if-then-else cannot hijack the redoip/redofr slots
|
|
% of p's frame, since this may not be (and usually won't be)
|
|
% on top when execution gets here.
|
|
( if
|
|
some [D] ( q(C, D) ; r(C, D) )
|
|
then
|
|
s(D, X)
|
|
else
|
|
s(C, X)
|
|
).
|
|
|
|
:- pred q(int::in, int::out) is nondet.
|
|
|
|
q(1, 15).
|
|
q(1, 16).
|
|
q(2, 25).
|
|
q(2, 26).
|
|
q(3, 35).
|
|
|
|
q(150, 660).
|
|
q(161, 661).
|
|
q(281, 662).
|
|
|
|
:- pred r(int::in, int::out) is nondet.
|
|
|
|
r(1, 18).
|
|
r(1, 19).
|
|
r(2, 28).
|
|
r(2, 29).
|
|
r(3, 38).
|
|
r(260, 690).
|
|
r(370, 698).
|
|
|
|
:- pred s(int::in, int::out) is nondet.
|
|
|
|
s(F, G) :-
|
|
F < 695,
|
|
(
|
|
G = 10 * F
|
|
;
|
|
G = 10 * F + 1
|
|
).
|
|
|
|
:- pred print_list(list(int), io__state, io__state).
|
|
:- mode print_list(in, di, uo) is det.
|
|
|
|
print_list(Xs) -->
|
|
(
|
|
{ Xs = [] }
|
|
->
|
|
io__write_string("[]\n")
|
|
;
|
|
io__write_string("["),
|
|
print_list_2(Xs),
|
|
io__write_string("]\n")
|
|
).
|
|
|
|
:- pred print_list_2(list(int), io__state, io__state).
|
|
:- mode print_list_2(in, di, uo) is det.
|
|
|
|
print_list_2([]) --> [].
|
|
print_list_2([X|Xs]) -->
|
|
io__write_int(X),
|
|
(
|
|
{ Xs = [] }
|
|
->
|
|
[]
|
|
;
|
|
io__write_string(", "),
|
|
print_list_2(Xs)
|
|
).
|