Files
mercury/tests/hard_coded/promise_equivalent_clauses.m
Julien Fischer 7368ea828b Delete the obsolete versions of the all-solutions predicates from std_util.m.
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.
2006-04-04 02:39:23 +00:00

53 lines
1.0 KiB
Mathematica

:- module promise_equivalent_clauses.
:- interface.
:- import_module io.
:- pred main(io::di, io::uo) is det.
:- implementation.
:- import_module list.
:- import_module solutions.
main(!IO) :-
SortedList = [1, 2, 3],
solutions(rev_sort(SortedList), RawLists),
list.foldl(test, RawLists, !IO).
:- pred test(list(T)::in, io::di, io::uo) is det.
test(RawList, !IO) :-
io.write(RawList, !IO),
io.write_string(" ", !IO),
rsort(RawList, SortedList),
io.write(SortedList, !IO),
io.nl(!IO).
:- pred rev_sort(list(T)::in, list(T)::out) is nondet.
rev_sort(SortedList, RawList) :-
rsort(RawList, SortedList).
:- pred rsort(list(T), list(T)).
:- mode rsort(in, out) is det.
:- mode rsort(out, in) is nondet.
:- pragma promise_equivalent_clauses(rsort/2).
rsort(Raw::in, Sorted::out) :-
list.sort(Raw, Sorted).
rsort(Raw::out, Sorted::in) :-
is_sorted(Sorted),
list.perm(Sorted, Raw).
:- pred is_sorted(list(T)::in) is semidet.
is_sorted([]).
is_sorted([_]).
is_sorted([A, B | Rest]) :-
compare(R, A, B),
( R = (<) ; R = (=) ),
is_sorted([B | Rest]).