[m-rev.] diff: more library cleanups (part 2)
Zoltan Somogyi
zs at cs.mu.OZ.AU
Tue Mar 16 10:43:18 AEDT 2004
Zoltan.
Index: library/set_bbbtree.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/library/set_bbbtree.m,v
retrieving revision 1.20
diff -u -b -r1.20 set_bbbtree.m
--- library/set_bbbtree.m 17 Aug 2003 13:30:12 -0000 1.20
+++ library/set_bbbtree.m 9 Mar 2004 16:43:41 -0000
@@ -20,27 +20,19 @@
:- type set_bbbtree(T).
-
% `set_bbbtree__init(Set)' returns an initialized empty set.
-:- pred set_bbbtree__init(set_bbbtree(T)).
-:- mode set_bbbtree__init(uo) is det.
-
+:- pred set_bbbtree__init(set_bbbtree(T)::uo) is det.
:- func set_bbbtree__init = set_bbbtree(T).
-
% `set_bbbtree__empty(Set) is true iff `Set' is contains no elements.
-:- pred set_bbbtree__empty(set_bbbtree(T)).
-:- mode set_bbbtree__empty(in) is semidet.
-
+:- pred set_bbbtree__empty(set_bbbtree(T)::in) is semidet.
% `set_bbbtree__size(Set, Size)' is true iff `Size' is the cardinality
% of `Set'.
-:- pred set_bbbtree__size(set_bbbtree(T), int).
-:- mode set_bbbtree__size(in, out) is det.
-
+:- pred set_bbbtree__size(set_bbbtree(T)::in, int::out) is det.
% `set_bbbtree__member(X, Set)' is true iff `X' is a member of `Set'.
% O(lg n) for (in, in) and O(1) for (out, in).
@@ -49,19 +41,15 @@
:- mode set_bbbtree__member(in, in) is semidet.
:- mode set_bbbtree__member(out, in) is nondet.
-
% `set_bbbtree__is_member(X, Set, Result)' is true iff `X' is a member
% of `Set'.
-:- pred set_bbbtree__is_member(T, set_bbbtree(T), bool).
-:- mode set_bbbtree__is_member(in, in, out) is det.
+:- pred set_bbbtree__is_member(T::in, set_bbbtree(T)::in, bool::out) is det.
% `set_bbbtree__contains(Set, X)' is true iff `X' is a member of `Set'.
% O(lg n).
-:- pred set_bbbtree__contains(set_bbbtree(T), T).
-:- mode set_bbbtree__contains(in, in) is semidet.
-
+:- pred set_bbbtree__contains(set_bbbtree(T)::in, T::in) is semidet.
% `set_bbbtree__least(Set, X)' is true iff `X' is smaller than all
% the other members of `Set'.
@@ -70,7 +58,6 @@
:- mode set_bbbtree__least(in, out) is semidet.
:- mode set_bbbtree__least(in, in) is semidet.
-
% `set_bbbtree__largest(Set, X)' is true iff `X' is larger than all
% the other members of `Set'.
@@ -78,7 +65,6 @@
:- mode set_bbbtree__largest(in, out) is semidet.
:- mode set_bbbtree__largest(in, in) is semidet.
-
% `set_bbbtree__singleton_set(Set, X)' is true iff `Set' is the set
% containing just the single element `X'.
@@ -90,13 +76,10 @@
:- func set_bbbtree__make_singleton_set(T) = set_bbbtree(T).
-
% `set_bbbtree__equal(SetA, SetB)' is true iff `SetA' and `SetB'
% contain the same elements.
-:- pred set_bbbtree__equal(set_bbbtree(T), set_bbbtree(T)).
-:- mode set_bbbtree__equal(in, in) is semidet.
-
+:- pred set_bbbtree__equal(set_bbbtree(T)::in, set_bbbtree(T)::in) is semidet.
% `set_bbbtree__insert(Set0, X, Set)' is true iff `Set' is the union of
% `Set0' and the set containing only `X'.
@@ -107,17 +90,14 @@
:- func set_bbbtree__insert(set_bbbtree(T), T) = set_bbbtree(T).
-
% `set_bbbtree__insert_list(Set0, Xs, Set)' is true iff `Set' is
% the union of `Set0' and the set containing only the members of `Xs'.
-:- pred set_bbbtree__insert_list(set_bbbtree(T), list(T), set_bbbtree(T)).
-% :- mode set_bbbtree__insert_list(di, di, uo) is det.
-:- mode set_bbbtree__insert_list(in, in, out) is det.
+:- pred set_bbbtree__insert_list(set_bbbtree(T)::in, list(T)::in,
+ set_bbbtree(T)::out) is det.
:- func set_bbbtree__insert_list(set_bbbtree(T), list(T)) = set_bbbtree(T).
-
% `set_bbbtree__delete(Set0, X, Set)' is true iff `Set' is the relative
% complement of `Set0' and the set containing only `X', i.e.
% if `Set' is the set which contains all the elements of `Set0'
@@ -129,73 +109,61 @@
:- func set_bbbtree__delete(set_bbbtree(T), T) = set_bbbtree(T).
-
% `set_bbbtree__delete_list(Set0, Xs, Set)' is true iff `Set' is the
% relative complement of `Set0' and the set containing only the members
% of `Xs'.
-:- pred set_bbbtree__delete_list(set_bbbtree(T), list(T), set_bbbtree(T)).
-% :- mode set_bbbtree__delete_list(di, in, uo) is det.
-:- mode set_bbbtree__delete_list(in, in, out) is det.
+:- pred set_bbbtree__delete_list(set_bbbtree(T)::in, list(T)::in,
+ set_bbbtree(T)::out) is det.
:- func set_bbbtree__delete_list(set_bbbtree(T), list(T)) = set_bbbtree(T).
-
% `set_bbbtree__remove(Set0, X, Set)' is true iff `Set0' contains `X',
% and `Set' is the relative complement of `Set0' and the set
% containing only `X', i.e. if `Set' is the set which contains
% all the elements of `Set0' except `X'.
-:- pred set_bbbtree__remove(set_bbbtree(T), T, set_bbbtree(T)).
-:- mode set_bbbtree__remove(in, in, out) is semidet.
-
+:- pred set_bbbtree__remove(set_bbbtree(T)::in, T::in, set_bbbtree(T)::out)
+ is semidet.
% `set_bbbtree__remove_list(Set0, Xs, Set)' is true iff Xs does not
% contain any duplicates, `Set0' contains every member of `Xs',
% and `Set' is the relative complement of `Set0' and the set
% containing only the members of `Xs'.
-:- pred set_bbbtree__remove_list(set_bbbtree(T), list(T), set_bbbtree(T)).
-:- mode set_bbbtree__remove_list(in, in, out) is semidet.
-
+:- pred set_bbbtree__remove_list(set_bbbtree(T)::in, list(T)::in,
+ set_bbbtree(T)::out) is semidet.
% `set_bbbtree__remove_least(Set0, X, Set)' is true iff the union if
% `X' and `Set' is `Set0' and `X' is smaller than all the elements of
% `Set'.
-:- pred set_bbbtree__remove_least(set_bbbtree(T), T, set_bbbtree(T)).
-:- mode set_bbbtree__remove_least(in, out, out) is semidet.
-
+:- pred set_bbbtree__remove_least(set_bbbtree(T)::in, T::out,
+ set_bbbtree(T)::out) is semidet.
% `set_bbbtree__remove_largest(Set0, X, Set)' is true iff the union if
% `X' and `Set' is `Set0' and `X' is larger than all the elements of
% `Set'.
-:- pred set_bbbtree__remove_largest(set_bbbtree(T), T, set_bbbtree(T)).
-:- mode set_bbbtree__remove_largest(in, out, out) is semidet.
-
+:- pred set_bbbtree__remove_largest(set_bbbtree(T)::in, T::out,
+ set_bbbtree(T)::out) is semidet.
% `set_bbbtree__list_to_set(List, Set)' is true iff `Set' is the set
% containing only the members of `List'. O(n lg n)
-:- pred set_bbbtree__list_to_set(list(T), set_bbbtree(T)).
-% :- mode set_bbbtree__list_to_set(di, uo) is det.
-:- mode set_bbbtree__list_to_set(in, out) is det.
+:- pred set_bbbtree__list_to_set(list(T)::in, set_bbbtree(T)::out) is det.
:- func set_bbbtree__list_to_set(list(T)) = set_bbbtree(T).
-
% `set_bbbtree__sorted_list_to_set(List, Set)' is true iff `Set' is the
% set containing only the members of `List'.
% `List' must be sorted. O(n).
-:- pred set_bbbtree__sorted_list_to_set(list(T), set_bbbtree(T)).
-% :- mode set_bbbtree__sorted_list_to_set(di, uo) is det.
-:- mode set_bbbtree__sorted_list_to_set(in, out) is det.
+:- pred set_bbbtree__sorted_list_to_set(list(T)::in, set_bbbtree(T)::out)
+ is det.
:- func set_bbbtree__sorted_list_to_set(list(T)) = set_bbbtree(T).
-
% `set_bbbtree__sorted_list_to_set_len(List, Set, N)' is true iff
% `Set' is the set set containing only the members of `List' and `N'
% is the length of the list. If the length of the list is already known
@@ -204,10 +172,8 @@
% with `set_bbbtree__sorted_list_to_set' is the call to list__length.
% `List' must be sorted. O(n).
-:- pred set_bbbtree__sorted_list_to_set_len(list(T), set_bbbtree(T), int).
-% :- mode set_bbbtree__sorted_list_to_set_len(di, uo, in) is det.
-:- mode set_bbbtree__sorted_list_to_set_len(in, out, in) is det.
-
+:- pred set_bbbtree__sorted_list_to_set_len(list(T)::in, set_bbbtree(T)::out,
+ int::in) is det.
% `set_bbbtree__to_sorted_list(Set, List)' is true iff `List' is the
% list of all the members of `Set', in sorted order. O(n).
@@ -218,16 +184,14 @@
:- func set_bbbtree__to_sorted_list(set_bbbtree(T)) = list(T).
-
% `set_bbbtree__union(SetA, SetB, Set)' is true iff `Set' is the union
% of `SetA' and `SetB'.
-:- pred set_bbbtree__union(set_bbbtree(T), set_bbbtree(T), set_bbbtree(T)).
-:- mode set_bbbtree__union(in, in, out) is det.
+:- pred set_bbbtree__union(set_bbbtree(T)::in, set_bbbtree(T)::in,
+ set_bbbtree(T)::out) is det.
:- func set_bbbtree__union(set_bbbtree(T), set_bbbtree(T)) = set_bbbtree(T).
-
% `set_bbbtree__union_list(Sets) = Set' is true iff `Set' is the union
% of all the sets in `Sets'
@@ -236,28 +200,24 @@
% `set_bbbtree__power_union(Sets, Set)' is true iff `Set' is the union
% of all the sets in `Sets'
-:- pred set_bbbtree__power_union(set_bbbtree(set_bbbtree(T)), set_bbbtree(T)).
-:- mode set_bbbtree__power_union(in, out) is det.
+:- pred set_bbbtree__power_union(set_bbbtree(set_bbbtree(T))::in,
+ set_bbbtree(T)::out) is det.
:- func set_bbbtree__power_union(set_bbbtree(set_bbbtree(T))) = set_bbbtree(T).
-
% `set_bbbtree__intersect(SetA, SetB, Set)' is true iff `Set' is the
% intersection of `SetA' and `SetB'.
-:- pred set_bbbtree__intersect(set_bbbtree(T), set_bbbtree(T),
- set_bbbtree(T)).
-:- mode set_bbbtree__intersect(in, in, out) is det.
+:- pred set_bbbtree__intersect(set_bbbtree(T)::in, set_bbbtree(T)::in,
+ set_bbbtree(T)::out) is det.
:- func set_bbbtree__intersect(set_bbbtree(T), set_bbbtree(T)) = set_bbbtree(T).
-
% `set_bbbtree__power_intersect(Sets, Set) is true iff `Set' is the
% intersection of the sets in `Sets'.
-:- pred set_bbbtree__power_intersect(set_bbbtree(set_bbbtree(T)),
- set_bbbtree(T)).
-:- mode set_bbbtree__power_intersect(in, out) is det.
+:- pred set_bbbtree__power_intersect(set_bbbtree(set_bbbtree(T))::in,
+ set_bbbtree(T)::out) is det.
:- func set_bbbtree__power_intersect(set_bbbtree(set_bbbtree(T)))
= set_bbbtree(T).
@@ -271,32 +231,27 @@
% set containing all the elements of `SetA' except those that
% occur in `SetB'.
-:- pred set_bbbtree__difference(set_bbbtree(T), set_bbbtree(T),
- set_bbbtree(T)).
-:- mode set_bbbtree__difference(in, in, out) is det.
+:- pred set_bbbtree__difference(set_bbbtree(T)::in, set_bbbtree(T)::in,
+ set_bbbtree(T)::out) is det.
:- func set_bbbtree__difference(set_bbbtree(T), set_bbbtree(T))
= set_bbbtree(T).
-
% `set_bbbtree__subset(SetA, SetB)' is true iff all the elements of
% `SetA' are also elements of `SetB'.
-:- pred set_bbbtree__subset(set_bbbtree(T), set_bbbtree(T)).
-:- mode set_bbbtree__subset(in, in) is semidet.
-
+:- pred set_bbbtree__subset(set_bbbtree(T)::in, set_bbbtree(T)::in) is semidet.
% `set_bbbtree__superset(SetA, SetB)' is true iff all the elements of
% `SetB' are also elements of `SetA'.
-:- pred set_bbbtree__superset(set_bbbtree(T), set_bbbtree(T)).
-:- mode set_bbbtree__superset(in, in) is semidet.
+:- pred set_bbbtree__superset(set_bbbtree(T)::in, set_bbbtree(T)::in)
+ is semidet.
:- func set_bbbtree__map(func(T1) = T2, set_bbbtree(T1)) = set_bbbtree(T2).
:- func set_bbbtree__filter_map(func(T1) = T2, set_bbbtree(T1))
= set_bbbtree(T2).
-
:- mode set_bbbtree__filter_map(func(in) = out is semidet, in) = out is det.
:- func set_bbbtree__fold(func(T1, T2) = T2, set_bbbtree(T1), T2) = T2.
@@ -348,16 +303,14 @@
%
%------------------------------------------------------------------------------%
-:- type set_bbbtree(T) --->
- empty
+:- type set_bbbtree(T)
+ ---> empty
; tree(T, int, set_bbbtree(T), set_bbbtree(T)).
-
% `set_bbbtree__def_ratio(Ratio)' returns the ratio that is used in
% deciding whether two trees require re-balancing.
-:- pred set_bbbtree__def_ratio(int).
-:- mode set_bbbtree__def_ratio(uo) is det.
+:- pred set_bbbtree__def_ratio(int::uo) is det.
set_bbbtree__def_ratio(5).
@@ -397,9 +350,7 @@
%------------------------------------------------------------------------------%
set_bbbtree__is_member(X, Set, Result) :-
- (
- set_bbbtree__member(X, Set)
- ->
+ ( set_bbbtree__member(X, Set) ->
Result = yes
;
Result = no
@@ -408,7 +359,6 @@
%------------------------------------------------------------------------------%
% set_bbbtree__least(empty, _) :- fail.
-
set_bbbtree__least(tree(V, _N, L, _R), X) :-
(
% found least element
@@ -423,7 +373,6 @@
%------------------------------------------------------------------------------%
% set_bbbtree__largest(empty, _) :- fail.
-
set_bbbtree__largest(tree(V, _N, _L, R), X) :-
(
% found largest element
@@ -453,20 +402,17 @@
set_bbbtree__insert_r(Set0, X, Set1, Ratio),
unsafe_promise_unique(Set1, Set).
-/* Uncomment this once destructive input and unique modes are fixed and detele
- the one above.
-set_bbbtree__insert(Set0, X, Set) :-
- set_bbbtree__def_ratio(Ratio),
- set_bbbtree__insert_r(Set0, X, Set, Ratio).
-*/
+% Uncomment this once destructive input and unique modes are fixed and delete
+% the one above.
+% set_bbbtree__insert(Set0, X, Set) :-
+% set_bbbtree__def_ratio(Ratio),
+% set_bbbtree__insert_r(Set0, X, Set, Ratio).
-:- pred set_bbbtree__insert_r(set_bbbtree(T), T, set_bbbtree(T), int).
-% :- mode set_bbbtree__insert_r(di, di, uo, in) is det.
-:- mode set_bbbtree__insert_r(in, in, out, in) is det.
+:- pred set_bbbtree__insert_r(set_bbbtree(T)::in, T::in, set_bbbtree(T)::out,
+ int::in) is det.
% X was not in the set so make new node with X as the value
set_bbbtree__insert_r(empty, X, tree(X, 1, empty, empty), _Ratio).
-
set_bbbtree__insert_r(tree(V, N, L, R), X, Set, Ratio) :-
compare(Result, X, V),
(
@@ -491,56 +437,46 @@
set_bbbtree__def_ratio(Ratio),
set_bbbtree__insert_list_r(Set0, List, Set, Ratio).
-:- pred set_bbbtree__insert_list_r(set_bbbtree(T), list(T), set_bbbtree(T),int).
-% :- mode set_bbbtree__insert_list_r(di, di, uo, in) is det.
-:- mode set_bbbtree__insert_list_r(in, in, out, in) is det.
+:- pred set_bbbtree__insert_list_r(set_bbbtree(T)::in, list(T)::in,
+ set_bbbtree(T)::out, int::in) is det.
set_bbbtree__insert_list_r(Set, [], Set, _Ratio).
-
set_bbbtree__insert_list_r(Set0, [X | Xs], Set, Ratio) :-
set_bbbtree__insert_r(Set0, X, Set1, Ratio),
set_bbbtree__insert_list_r(Set1, Xs, Set, Ratio).
%------------------------------------------------------------------------------%
-/*
-set_bbbtree__delete(empty, _X, empty).
-set_bbbtree__delete(tree(V, N, L, R), X, Set) :-
- compare(Result, X, V),
- (
- % delete X from left subtree
- Result = (<),
- set_bbbtree__delete(L, X, NewL), % X in left tree
- NewN = N - 1,
- Set = tree(V, NewN, NewL, R)
- ;
- % delete X from right subtree
- Result = (>),
- set_bbbtree__delete(R, X, NewR), % X in right tree
- NewN = N - 1,
- Set = tree(V, NewN, L, NewR)
- ;
- % found X so just concatenate its two subtrees together
- Result = (=),
- set_bbbtree__concat3(L, R, Set)
- ).
-*/
-
-/*
-set_bbbtree__delete(Set0, X, Set) :-
- (
- set_bbbtree__remove(Set0, X, Set1)
- ->
- Set = Set1
- ;
- Set = Set0
- ).
-*/
+% set_bbbtree__delete(empty, _X, empty).
+% set_bbbtree__delete(tree(V, N, L, R), X, Set) :-
+% compare(Result, X, V),
+% (
+% % delete X from left subtree
+% Result = (<),
+% set_bbbtree__delete(L, X, NewL), % X in left tree
+% NewN = N - 1,
+% Set = tree(V, NewN, NewL, R)
+% ;
+% % delete X from right subtree
+% Result = (>),
+% set_bbbtree__delete(R, X, NewR), % X in right tree
+% NewN = N - 1,
+% Set = tree(V, NewN, L, NewR)
+% ;
+% % found X so just concatenate its two subtrees together
+% Result = (=),
+% set_bbbtree__concat3(L, R, Set)
+% ).
+%
+% set_bbbtree__delete(Set0, X, Set) :-
+% ( set_bbbtree__remove(Set0, X, Set1) ->
+% Set = Set1
+% ;
+% Set = Set0
+% ).
set_bbbtree__delete(Set0, X, Set) :-
- (
- set_bbbtree__remove(Set0, X, Set1)
- ->
+ ( set_bbbtree__remove(Set0, X, Set1) ->
Set2 = Set1
;
Set2 = Set0
@@ -550,7 +486,6 @@
%------------------------------------------------------------------------------%
set_bbbtree__delete_list(Set, [], Set).
-
set_bbbtree__delete_list(Set0, [X | Xs], Set) :-
set_bbbtree__delete(Set0, X, Set1),
set_bbbtree__delete_list(Set1, Xs, Set).
@@ -558,7 +493,6 @@
%------------------------------------------------------------------------------%
% set_bbbtree__remove(empty, X, _):- fail.
-
set_bbbtree__remove(tree(V, N, L, R), X, Set) :-
compare(Result, X, V),
(
@@ -582,7 +516,6 @@
%------------------------------------------------------------------------------%
set_bbbtree__remove_list(Set, [], Set).
-
set_bbbtree__remove_list(Set0, [X | Xs], Set) :-
set_bbbtree__remove(Set0, X, Set1),
set_bbbtree__remove_list(Set1, Xs, Set).
@@ -593,7 +526,6 @@
% tree to become much more unbalanced.
% set_bbbtree__remove_least(empty, X, _) :- fail.
-
set_bbbtree__remove_least(tree(V, N, L, R), X, Set) :-
(
% found the least element
@@ -614,7 +546,6 @@
% tree to become much more unbalanced.
% set_bbbtree__remove_largest(empty, X, _) :- fail.
-
set_bbbtree__remove_largest(tree(V, N, L, R), X, Set) :-
(
% found the largest element
@@ -635,9 +566,8 @@
set_bbbtree__def_ratio(Ratio),
set_bbbtree__list_to_set_r(List, Set, Ratio).
-:- pred set_bbbtree__list_to_set_r(list(T), set_bbbtree(T), int).
-% :- mode set_bbbtree__list_to_set_r(di, uo, in) is det.
-:- mode set_bbbtree__list_to_set_r(in, out, in) is det.
+:- pred set_bbbtree__list_to_set_r(list(T)::in, set_bbbtree(T)::out, int::in)
+ is det.
set_bbbtree__list_to_set_r(List, Set, Ratio) :-
set_bbbtree__init(InitSet),
@@ -665,26 +595,21 @@
set_bbbtree__sorted_list_to_set_len(List, Set, N).
set_bbbtree__sorted_list_to_set_len([], empty, _N).
-set_bbbtree__sorted_list_to_set_len([ X | Xs ], Set, N) :-
- set_bbbtree__sorted_list_to_set_len2([ X | Xs ], RestOfList, N, Set),
- (
- RestOfList = [] % The list should be exhaused on completion
- ->
+set_bbbtree__sorted_list_to_set_len([X | Xs], Set, N) :-
+ set_bbbtree__sorted_list_to_set_len2([X | Xs], RestOfList, N, Set),
+ % The list should be exhausted on completion
+ ( RestOfList = [] ->
true
;
- % Should never happen. Here only to satify det checker
+ % Should never happen. Here only to satisfy det checker
error("set_bbbtree__sorted_list_to_set_r")
).
-:- pred set_bbbtree__sorted_list_to_set_len2(list(T), list(T), int,
- set_bbbtree(T)).
-% :- mode set_bbbtree__sorted_list_to_set_len2(di, uo, in, uo) is det.
-:- mode set_bbbtree__sorted_list_to_set_len2(in, out, in, out) is det.
+:- pred set_bbbtree__sorted_list_to_set_len2(list(T)::in, list(T)::out,
+ int::in, set_bbbtree(T)::out) is det.
set_bbbtree__sorted_list_to_set_len2(List, RestOfList, N, Set) :-
- (
- N > 3
- ->
+ ( N > 3 ->
NL = N//2,
NR = N - NL - 1,
set_bbbtree__sorted_list_to_set_len2(List, RestOfList0, NL, L),
@@ -699,37 +624,26 @@
RestOfList0 = [],
error("set_bbbtree__sorted_list_to_set_len2.1")
)
- ;
- N = 3
- ->
- (
- List = [ X, Y, Z | RestOfList0 ]
- ->
+ ; N = 3 ->
+ ( List = [X, Y, Z | RestOfList0] ->
RestOfList = RestOfList0,
- Set = tree(Y, N, tree(X, 1, empty, empty),
+ Set = tree(Y, N,
+ tree(X, 1, empty, empty),
tree(Z, 1, empty, empty))
;
% Should never occur.Here only to satisfy det checker
error("set_bbbtree__sorted_list_to_set_len2.2")
)
- ;
- N = 2
- ->
- (
- List = [ X, Y | RestOfList0 ]
- ->
+ ; N = 2 ->
+ ( List = [X, Y | RestOfList0] ->
RestOfList = RestOfList0,
Set = tree(Y, N, tree(X, 1, empty, empty), empty)
;
% Should never occur. Here only to satisfy det checker
error("set_bbbtree__sorted_list_to_set_len2.3")
)
- ;
- N = 1
- ->
- (
- List = [ X | RestOfList0 ]
- ->
+ ; N = 1 ->
+ ( List = [X | RestOfList0] ->
RestOfList = RestOfList0,
Set = tree(X, N, empty, empty)
;
@@ -773,9 +687,8 @@
set_bbbtree__def_ratio(Ratio),
set_bbbtree__union_r(SetA, SetB, Set, Ratio).
-:- pred set_bbbtree__union_r(set_bbbtree(T),set_bbbtree(T),set_bbbtree(T),int).
-% :- mode set_bbbtree__union_r(di, di, uo, in) is det.
-:- mode set_bbbtree__union_r(in, in, out, in) is det.
+:- pred set_bbbtree__union_r(set_bbbtree(T)::in, set_bbbtree(T)::in,
+ set_bbbtree(T)::out, int::in) is det.
set_bbbtree__union_r(empty, Set, Set, _Ratio).
@@ -807,12 +720,10 @@
set_bbbtree__def_ratio(Ratio),
set_bbbtree__power_union_r(Sets, Set, Ratio).
-:- pred set_bbbtree__power_union_r(set_bbbtree(set_bbbtree(T)),
- set_bbbtree(T), int).
-:- mode set_bbbtree__power_union_r(in, out, in) is det.
+:- pred set_bbbtree__power_union_r(set_bbbtree(set_bbbtree(T))::in,
+ set_bbbtree(T)::out, int::in) is det.
set_bbbtree__power_union_r(empty, empty, _Ratio).
-
set_bbbtree__power_union_r(tree(V, _N, L, R), Set, Ratio) :-
set_bbbtree__power_union_r(L, LUnion, Ratio),
set_bbbtree__power_union_r(R, RUnion, Ratio),
@@ -832,21 +743,16 @@
set_bbbtree__def_ratio(Ratio),
set_bbbtree__intersect_r(SetA, SetB, Set, Ratio).
-:- pred set_bbbtree__intersect_r(set_bbbtree(T), set_bbbtree(T),
- set_bbbtree(T), int).
-% :- mode set_bbbtree__intersect_r(di, di, uo, in) is det.
-:- mode set_bbbtree__intersect_r(in, in, out, in) is det.
+:- pred set_bbbtree__intersect_r(set_bbbtree(T)::in, set_bbbtree(T)::in,
+ set_bbbtree(T)::out, int::in) is det.
set_bbbtree__intersect_r(empty, _Set, empty, _Ratio).
-
set_bbbtree__intersect_r(tree(V, _N, LL, LR), R, Set, Ratio) :-
set_bbbtree__split_lt(R, V, NewRL, Ratio),
set_bbbtree__split_gt(R, V, NewRR, Ratio),
set_bbbtree__intersect_r(LL, NewRL, LSet, Ratio),
set_bbbtree__intersect_r(LR, NewRR, RSet, Ratio),
- (
- set_bbbtree__member(V, R)
- ->
+ ( set_bbbtree__member(V, R) ->
set_bbbtree__concat4(LSet, RSet, V, Set, Ratio)
;
set_bbbtree__concat3(LSet, RSet, Set)
@@ -865,31 +771,26 @@
set_bbbtree__def_ratio(Ratio),
set_bbbtree__power_intersect_r(Sets, Set, Ratio).
-:- pred set_bbbtree__power_intersect_r(set_bbbtree(set_bbbtree(T)),
- set_bbbtree(T), int).
-:- mode set_bbbtree__power_intersect_r(in, out, in) is det.
+:- pred set_bbbtree__power_intersect_r(set_bbbtree(set_bbbtree(T))::in,
+ set_bbbtree(T)::out, int::in) is det.
set_bbbtree__power_intersect_r(empty, empty, _Ratio).
-
set_bbbtree__power_intersect_r(tree(V, _N, L, R), Set, Ratio) :-
set_bbbtree__power_intersect_r2(L, V, Intersection0, Ratio),
set_bbbtree__power_intersect_r2(R, Intersection0, Set, Ratio).
-:- pred set_bbbtree__power_intersect_r2(set_bbbtree(set_bbbtree(T)),
- set_bbbtree(T), set_bbbtree(T), int).
-:- mode set_bbbtree__power_intersect_r2(in, in, out, in) is det.
+:- pred set_bbbtree__power_intersect_r2(set_bbbtree(set_bbbtree(T))::in,
+ set_bbbtree(T)::in, set_bbbtree(T)::out, int::in) is det.
set_bbbtree__power_intersect_r2(empty, empty, empty, _Ratio).
-
set_bbbtree__power_intersect_r2(empty, tree(_V, _N, _L, _R), empty, _Ratio).
-
set_bbbtree__power_intersect_r2(tree(_V, _N, _L, _R), empty, empty, _Ratio).
-
set_bbbtree__power_intersect_r2(tree(V, _N, L, R), tree(AccV, AccN, AccL, AccR),
Set, Ratio) :-
set_bbbtree__intersect_r(V, tree(AccV, AccN, AccL, AccR),
Intersection0, Ratio),
- set_bbbtree__power_intersect_r2(L, Intersection0, Intersection1, Ratio),
+ set_bbbtree__power_intersect_r2(L, Intersection0,
+ Intersection1, Ratio),
set_bbbtree__power_intersect_r2(R, Intersection1, Set, Ratio).
set_bbbtree__intersect_list([]) = set_bbbtree__init.
@@ -918,21 +819,16 @@
set_bbbtree__def_ratio(Ratio),
set_bbbtree__difference_r(SetA, SetB, Set, Ratio).
-:- pred set_bbbtree__difference_r(set_bbbtree(T), set_bbbtree(T),
- set_bbbtree(T), int).
-% :- mode set_bbbtree__difference_r(di, di, uo, in) is det.
-:- mode set_bbbtree__difference_r(in, in, out, in) is det.
+:- pred set_bbbtree__difference_r(set_bbbtree(T)::in, set_bbbtree(T)::in,
+ set_bbbtree(T)::out, int::in) is det.
set_bbbtree__difference_r(empty, _Set, empty, _Ratio).
-
set_bbbtree__difference_r(tree(V, _N, LL, LR), R, Set, Ratio) :-
set_bbbtree__split_lt(R, V, NewRL, Ratio),
set_bbbtree__split_gt(R, V, NewRR, Ratio),
set_bbbtree__difference_r(LL, NewRL, LSet, Ratio),
set_bbbtree__difference_r(LR, NewRR, RSet, Ratio),
- (
- set_bbbtree__member(V, R)
- ->
+ ( set_bbbtree__member(V, R) ->
set_bbbtree__concat3(LSet, RSet, Set)
;
set_bbbtree__concat4(LSet, RSet, V, Set, Ratio)
@@ -955,10 +851,8 @@
% given X, L and R create a new tree who's root is X,
% left subtree is L and right subtree is R.
-:- pred set_bbbtree__build_node(T, set_bbbtree(T), set_bbbtree(T),
- set_bbbtree(T)).
-% :- mode set_bbbtree__build_node(di, di, di, uo) is det. % unused
-:- mode set_bbbtree__build_node(in, in, in, out) is det.
+:- pred set_bbbtree__build_node(T::in, set_bbbtree(T)::in, set_bbbtree(T)::in,
+ set_bbbtree(T)::out) is det.
set_bbbtree__build_node(X, L, R, Tree) :-
set_bbbtree__size(L, LSize),
@@ -977,14 +871,11 @@
% / \ / \
% Y Z X Y
-:- pred set_bbbtree__single_rot_l(T, set_bbbtree(T), set_bbbtree(T),
- set_bbbtree(T)).
-% :- mode set_bbbtree__single_rot_l(di, di, di, uo) is det. % unused
-:- mode set_bbbtree__single_rot_l(in, in, in, out) is det.
-
-set_bbbtree__single_rot_l(_A, _X, empty, _Set) :- % Should never occur. Here
- error("set_bbbtree__single_rot_l"). % only to satisfy det checker
+:- pred set_bbbtree__single_rot_l(T::in, set_bbbtree(T)::in,
+ set_bbbtree(T)::in, set_bbbtree(T)::out) is det.
+set_bbbtree__single_rot_l(_A, _X, empty, _Set) :-
+ error("set_bbbtree__single_rot_l").
set_bbbtree__single_rot_l(A, X, tree(B, _N, Y, Z), Set) :-
set_bbbtree__build_node(A, X, Y, A_X_and_Y),
set_bbbtree__build_node(B, A_X_and_Y, Z, Set).
@@ -993,14 +884,11 @@
% Single rotation to the right.
-:- pred set_bbbtree__single_rot_r(T, set_bbbtree(T), set_bbbtree(T),
- set_bbbtree(T)).
-% :- mode set_bbbtree__single_rot_r(di, di, di, uo) is det. % unused
-:- mode set_bbbtree__single_rot_r(in, in, in, out) is det.
-
-set_bbbtree__single_rot_r(_B, empty, _Z, _Set) :- % Should never occur. Here
- error("set_bbbtree__single_rot_r"). % only to satisfy det checker
+:- pred set_bbbtree__single_rot_r(T::in, set_bbbtree(T)::in,
+ set_bbbtree(T)::in, set_bbbtree(T)::out) is det.
+set_bbbtree__single_rot_r(_B, empty, _Z, _Set) :-
+ error("set_bbbtree__single_rot_r").
set_bbbtree__single_rot_r(B, tree(A, _N, X, Y), Z, Set) :-
set_bbbtree__build_node(B, Y, Z, B_Y_and_Z),
set_bbbtree__build_node(A, X, B_Y_and_Z, Set).
@@ -1017,14 +905,11 @@
% / \ X Y1 Y2 Z
% Y1 Y2
-:- pred set_bbbtree__double_rot_l(T, set_bbbtree(T), set_bbbtree(T),
- set_bbbtree(T)).
-% :- mode set_bbbtree__double_rot_l(di, di, di, uo) is det. % unused
-:- mode set_bbbtree__double_rot_l(in, in, in, out) is det.
-
-set_bbbtree__double_rot_l(_A, _X, empty, _Set) :- % Should never occur. Here
- error("set_bbbtree__double_rot_l.1"). % only to satisfy det checker
+:- pred set_bbbtree__double_rot_l(T::in, set_bbbtree(T)::in,
+ set_bbbtree(T)::in, set_bbbtree(T)::out) is det.
+set_bbbtree__double_rot_l(_A, _X, empty, _Set) :-
+ error("set_bbbtree__double_rot_l.1").
set_bbbtree__double_rot_l(A, X, tree(C, _N0, Y, Z), Set) :-
(
Y = tree(B, _N1, Y1, Y2),
@@ -1032,7 +917,6 @@
set_bbbtree__build_node(C, Y2, Z, C_Y2_and_Z),
set_bbbtree__build_node(B, A_X_and_Y1, C_Y2_and_Z, Set)
;
- % Should never occur. Here only to satisfy det checker
Y = empty,
error("set_bbbtree__double_rot_l.2")
).
@@ -1041,14 +925,11 @@
% Double rotation to the right.
-:- pred set_bbbtree__double_rot_r(T, set_bbbtree(T), set_bbbtree(T),
- set_bbbtree(T)).
-% :- mode set_bbbtree__double_rot_r(di, di, di, uo) is det. % unused
-:- mode set_bbbtree__double_rot_r(in, in, in, out) is det.
-
-set_bbbtree__double_rot_r(_B, empty, _Z, _Set) :- % Should never occur. Here
- error("set_bbbtree__double_rot_r.1"). % only to satisfy det checker
+:- pred set_bbbtree__double_rot_r(T::in, set_bbbtree(T)::in,
+ set_bbbtree(T)::in, set_bbbtree(T)::out) is det.
+set_bbbtree__double_rot_r(_B, empty, _Z, _Set) :-
+ error("set_bbbtree__double_rot_r.1").
set_bbbtree__double_rot_r(C, tree(A, _N0, X, Y), Z, Set) :-
(
Y = tree(B, _N1, Y1, Y2),
@@ -1056,7 +937,6 @@
set_bbbtree__build_node(C, Y2, Z, C_Y2_and_Z),
set_bbbtree__build_node(B, A_X_and_Y1, C_Y2_and_Z, Set)
;
- % Should never occur. Here only to satisfy det checker
Y = empty,
error("set_bbbtree__double_rot_r.2")
).
@@ -1068,10 +948,8 @@
% construct a new tree consisting of V, L and R that is balanced by the use of
% single and double left and right rotations.
-:- pred set_bbbtree__balance(T, set_bbbtree(T), set_bbbtree(T),
- set_bbbtree(T), int).
-% :- mode set_bbbtree__balance(di, di, di, uo, in) is det.
-:- mode set_bbbtree__balance(in, in, in, out, in) is det.
+:- pred set_bbbtree__balance(T::in, set_bbbtree(T)::in, set_bbbtree(T)::in,
+ set_bbbtree(T)::out, int::in) is det.
set_bbbtree__balance(V, L, R, Set, Ratio) :-
set_bbbtree__size(L, LSize),
@@ -1087,8 +965,7 @@
RSize > Val
->
(
- R = tree(_V0, _N0, RL, RR)
- ->
+ R = tree(_V0, _N0, RL, RR),
set_bbbtree__size(RL, RLSize), % right side too big
set_bbbtree__size(RR, RRSize),
(
@@ -1099,7 +976,7 @@
set_bbbtree__double_rot_l(V, L, R, Set)
)
;
- % Should never occur. Here only to satisfy det checker
+ R = empty,
error("set_bbbtree__balance.1")
)
;
@@ -1107,8 +984,7 @@
LSize > Val
->
(
- L = tree(_V1, _N1, LL, LR)
- ->
+ L = tree(_V1, _N1, LL, LR),
set_bbbtree__size(LL, LLSize), % left side too big
set_bbbtree__size(LR, LRSize),
(
@@ -1119,7 +995,7 @@
set_bbbtree__double_rot_r(V, L, R, Set)
)
;
- % Should never occur. Here only to satisfy det checker
+ L = empty,
error("set_bbbtree__balance.2")
)
;
@@ -1136,9 +1012,8 @@
% elements. This predicate should not be confused with the predicate `concat3'
% in the paper for that is `set_bbbtree__concat4'.
-:- pred set_bbbtree__concat3(set_bbbtree(T),set_bbbtree(T),set_bbbtree(T)).
-% :- mode set_bbbtree__concat3(di, di, uo) is det.
-:- mode set_bbbtree__concat3(in, in, out) is det.
+:- pred set_bbbtree__concat3(set_bbbtree(T)::in, set_bbbtree(T)::in,
+ set_bbbtree(T)::out) is det.
set_bbbtree__concat3(L, R, Set) :-
set_bbbtree__size(L, LSize),
@@ -1162,23 +1037,17 @@
(
LSize > RSize
->
- (
- set_bbbtree__remove_largest(L, X, NewL)
- ->
- set_bbbtree__build_node(X, NewL, R, Set)
+ ( set_bbbtree__remove_largest(L, X, NewL) ->
+ set_bbbtree__build_node(X, NewL, R,
+ Set)
;
- % Should never happen. Here only
- % to satisfy the det checker.
error("set_bbbtree__concat3.1")
)
;
- (
- set_bbbtree__remove_least(R, X, NewR)
- ->
- set_bbbtree__build_node(X, L, NewR, Set)
+ ( set_bbbtree__remove_least(R, X, NewR) ->
+ set_bbbtree__build_node(X, L, NewR,
+ Set)
;
- % Should never happen. Here only
- % to satisfy the det checker.
error("set_bbbtree__concat3.2")
)
)
@@ -1192,10 +1061,8 @@
% construct a new tree consisting of V and the elements of L and R.
% This predicate is the equivalent of concat3 in the paper.
-:- pred set_bbbtree__concat4(set_bbbtree(T), set_bbbtree(T), T,
- set_bbbtree(T), int).
-% :- mode set_bbbtree__concat4(di, di, di, uo, in) is det.
-:- mode set_bbbtree__concat4(in, in, in, out, in) is det.
+:- pred set_bbbtree__concat4(set_bbbtree(T)::in, set_bbbtree(T)::in, T::in,
+ set_bbbtree(T)::out, int::in) is det.
set_bbbtree__concat4(empty, R, V, Set, Ratio) :-
set_bbbtree__insert_r(R, V, Set, Ratio).
@@ -1229,11 +1096,10 @@
% Given a set return the subset that is less that X
-:- pred set_bbbtree__split_lt(set_bbbtree(T), T, set_bbbtree(T), int).
-:- mode set_bbbtree__split_lt(in, in, out, in) is det.
+:- pred set_bbbtree__split_lt(set_bbbtree(T)::in, T::in, set_bbbtree(T)::out,
+ int::in) is det.
set_bbbtree__split_lt(empty, _X, empty, _Ratio).
-
set_bbbtree__split_lt(tree(V, _N, L, R), X, Set, Ratio) :-
compare(Result, X, V),
(
@@ -1252,11 +1118,10 @@
% Given a set return the subset of it that is greater that X
-:- pred set_bbbtree__split_gt(set_bbbtree(T), T, set_bbbtree(T), int).
-:- mode set_bbbtree__split_gt(in, in, out, in) is det.
+:- pred set_bbbtree__split_gt(set_bbbtree(T)::in, T::in, set_bbbtree(T)::out,
+ int::in) is det.
set_bbbtree__split_gt(empty, _X, empty, _Ratio).
-
set_bbbtree__split_gt(tree(V, _N, L, R), X, Set, Ratio) :-
compare(Result, X, V),
(
@@ -1328,4 +1193,3 @@
set_bbbtree__fold(F, S, A) = B :-
B = list__foldl(F, set_bbbtree__to_sorted_list(S), A).
-
Index: library/set_ordlist.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/library/set_ordlist.m,v
retrieving revision 1.15
diff -u -b -r1.15 set_ordlist.m
--- library/set_ordlist.m 19 Feb 2002 09:25:28 -0000 1.15
+++ library/set_ordlist.m 9 Mar 2004 16:35:48 -0000
@@ -22,32 +22,25 @@
% `set_ordlist__list_to_set(List, Set)' is true iff `Set' is the set
% containing only the members of `List'.
-:- pred set_ordlist__list_to_set(list(T), set_ordlist(T)).
-:- mode set_ordlist__list_to_set(in, out) is det.
-
+:- pred set_ordlist__list_to_set(list(T)::in, set_ordlist(T)::out) is det.
:- func set_ordlist__list_to_set(list(T)) = set_ordlist(T).
% `set_ordlist__sorted_list_to_set(List, Set)' is true iff `Set' is
% the set containing only the members of `List'. `List' must be sorted.
-:- pred set_ordlist__sorted_list_to_set(list(T), set_ordlist(T)).
-:- mode set_ordlist__sorted_list_to_set(in, out) is det.
-
+:- pred set_ordlist__sorted_list_to_set(list(T)::in, set_ordlist(T)::out)
+ is det.
:- func set_ordlist__sorted_list_to_set(list(T)) = set_ordlist(T).
% `set_ordlist__to_sorted_list(Set, List)' is true iff `List' is the
% list of all the members of `Set', in sorted order.
-:- pred set_ordlist__to_sorted_list(set_ordlist(T), list(T)).
-:- mode set_ordlist__to_sorted_list(in, out) is det.
-
+:- pred set_ordlist__to_sorted_list(set_ordlist(T)::in, list(T)::out) is det.
:- func set_ordlist__to_sorted_list(set_ordlist(T)) = list(T).
% `set_ordlist__init(Set)' is true iff `Set' is an empty set.
-:- pred set_ordlist__init(set_ordlist(_T)).
-:- mode set_ordlist__init(uo) is det.
-
+:- pred set_ordlist__init(set_ordlist(_T)::uo) is det.
:- func set_ordlist__init = set_ordlist(T).
% `set_ordlist__singleton_set(Set, Elem)' is true iff `Set' is the set
@@ -62,25 +55,22 @@
% `set_ordlist__equal(SetA, SetB)' is true iff
% `SetA' and `SetB' contain the same elements.
-:- pred set_ordlist__equal(set_ordlist(T), set_ordlist(T)).
-:- mode set_ordlist__equal(in, in) is semidet.
+:- pred set_ordlist__equal(set_ordlist(T)::in, set_ordlist(T)::in) is semidet.
% `set_ordlist__empty(Set)' is true iff `Set' is an empty set.
-:- pred set_ordlist__empty(set_ordlist(_T)).
-:- mode set_ordlist__empty(in) is semidet.
+:- pred set_ordlist__empty(set_ordlist(_T)::in) is semidet.
% `set_ordlist__subset(SetA, SetB)' is true iff `SetA' is a subset of
% `SetB'.
-:- pred set_ordlist__subset(set_ordlist(T), set_ordlist(T)).
-:- mode set_ordlist__subset(in, in) is semidet.
+:- pred set_ordlist__subset(set_ordlist(T)::in, set_ordlist(T)::in) is semidet.
% `set_ordlist__superset(SetA, SetB)' is true iff `SetA' is a
% superset of `SetB'.
-:- pred set_ordlist__superset(set_ordlist(T), set_ordlist(T)).
-:- mode set_ordlist__superset(in, in) is semidet.
+:- pred set_ordlist__superset(set_ordlist(T)::in, set_ordlist(T)::in)
+ is semidet.
% `set_ordlist__member(X, Set)' is true iff `X' is a member of `Set'.
@@ -91,13 +81,11 @@
% `set_ordlist__is_member(X, Set, Result)' returns
% `Result = yes' iff `X' is a member of `Set'.
-:- pred set_ordlist__is_member(T, set_ordlist(T), bool).
-:- mode set_ordlist__is_member(in, in, out) is det.
+:- pred set_ordlist__is_member(T::in, set_ordlist(T)::in, bool::out) is det.
% `set_ordlist__contains(Set, X)' is true iff `X' is a member of `Set'.
-:- pred set_ordlist__contains(set_ordlist(T), T).
-:- mode set_ordlist__contains(in, in) is semidet.
+:- pred set_ordlist__contains(set_ordlist(T)::in, T::in) is semidet.
% `set_ordlist__insert(Set0, X, Set)' is true iff `Set' is the union
% of `Set0' and the set containing only `X'.
@@ -111,9 +99,8 @@
% `set_ordlist__insert_list(Set0, Xs, Set)' is true iff `Set' is the
% union of `Set0' and the set containing only the members of `Xs'.
-:- pred set_ordlist__insert_list(set_ordlist(T), list(T), set_ordlist(T)).
-:- mode set_ordlist__insert_list(in, in, out) is det.
-
+:- pred set_ordlist__insert_list(set_ordlist(T)::in, list(T)::in,
+ set_ordlist(T)::out) is det.
:- func set_ordlist__insert_list(set_ordlist(T), list(T)) = set_ordlist(T).
% `set_ordlist__delete(Set0, X, Set)' is true iff `Set' is the
@@ -121,19 +108,16 @@
% if `Set' is the set which contains all the elements of `Set0'
% except `X'.
-:- pred set_ordlist__delete(set_ordlist(T), T, set_ordlist(T)).
-% :- mode set_ordlist__delete(di, in, uo) is det.
-:- mode set_ordlist__delete(in, in, out) is det.
-
+:- pred set_ordlist__delete(set_ordlist(T)::in, T::in, set_ordlist(T)::out)
+ is det.
:- func set_ordlist__delete(set_ordlist(T), T) = set_ordlist(T).
% `set_ordlist__delete_list(Set0, Xs, Set)' is true iff `Set' is the
% relative complement of `Set0' and the set containing only the members
% of `Xs'.
-:- pred set_ordlist__delete_list(set_ordlist(T), list(T), set_ordlist(T)).
-:- mode set_ordlist__delete_list(in, in, out) is det.
-
+:- pred set_ordlist__delete_list(set_ordlist(T)::in, list(T)::in,
+ set_ordlist(T)::out) is det.
:- func set_ordlist__delete_list(set_ordlist(T), list(T)) = set_ordlist(T).
% `set_ordlist__remove(Set0, X, Set)' is true iff `Set0' contains `X',
@@ -141,32 +125,31 @@
% containing only `X', i.e. if `Set' is the set which contains
% all the elements of `Set0' except `X'.
-:- pred set_ordlist__remove(set_ordlist(T), T, set_ordlist(T)).
-:- mode set_ordlist__remove(in, in, out) is semidet.
+:- pred set_ordlist__remove(set_ordlist(T)::in, T::in, set_ordlist(T)::out)
+ is semidet.
% `set_ordlist__remove_list(Set0, Xs, Set)' is true iff Xs does not
% contain any duplicates, `Set0' contains every member of `Xs',
% and `Set' is the relative complement of `Set0' and the set
% containing only the members of `Xs'.
-:- pred set_ordlist__remove_list(set_ordlist(T), list(T), set_ordlist(T)).
-:- mode set_ordlist__remove_list(in, in, out) is semidet.
+:- pred set_ordlist__remove_list(set_ordlist(T)::in, list(T)::in,
+ set_ordlist(T)::out) is semidet.
% `set_ordlist__remove_least(Set0, X, Set)' is true iff `X' is the
% least element in `Set0', and `Set' is the set which contains all the
% elements of `Set0' except `X'.
-:- pred set_ordlist__remove_least(set_ordlist(T), T, set_ordlist(T)).
-:- mode set_ordlist__remove_least(in, out, out) is semidet.
+:- pred set_ordlist__remove_least(set_ordlist(T)::in, T::out,
+ set_ordlist(T)::out) is semidet.
% `set_ordlist_union(SetA, SetB, Set)' is true iff `Set' is the union
% of `SetA' and `SetB'. The efficiency of the union operation is
% O(card(SetA)+card(SetB)) and is not sensitive to the argument
% ordering.
-:- pred set_ordlist__union(set_ordlist(T), set_ordlist(T),
- set_ordlist(T)).
-:- mode set_ordlist__union(in, in, out) is det.
+:- pred set_ordlist__union(set_ordlist(T)::in, set_ordlist(T)::in,
+ set_ordlist(T)::out) is det.
:- func set_ordlist__union(set_ordlist(T), set_ordlist(T)) = set_ordlist(T).
@@ -178,9 +161,8 @@
% `set_ordlist__power_union(A, B)' is true iff `B' is the union of
% all the sets in `A'
-:- pred set_ordlist__power_union(set_ordlist(set_ordlist(T)),
- set_ordlist(T)).
-:- mode set_ordlist__power_union(in, out) is det.
+:- pred set_ordlist__power_union(set_ordlist(set_ordlist(T))::in,
+ set_ordlist(T)::out) is det.
:- func set_ordlist__power_union(set_ordlist(set_ordlist(T))) = set_ordlist(T).
@@ -188,8 +170,7 @@
% intersection of `SetA' and `SetB'. The efficiency of the intersection
% operation is not influenced by the argument order.
-:- pred set_ordlist__intersect(set_ordlist(T), set_ordlist(T),
- set_ordlist(T)).
+:- pred set_ordlist__intersect(set_ordlist(T), set_ordlist(T), set_ordlist(T)).
:- mode set_ordlist__intersect(in, in, out) is det.
:- mode set_ordlist__intersect(in, in, in) is semidet.
@@ -199,10 +180,8 @@
% `set_ordlist__power_intersect(A, B)' is true iff `B' is the
% intersection of all the sets in `A'.
-:- pred set_ordlist__power_intersect(set_ordlist(set_ordlist(T)),
- set_ordlist(T)).
-:- mode set_ordlist__power_intersect(in, out) is det.
-
+:- pred set_ordlist__power_intersect(set_ordlist(set_ordlist(T))::in,
+ set_ordlist(T)::out) is det.
:- func set_ordlist__power_intersect(set_ordlist(set_ordlist(T)))
= set_ordlist(T).
@@ -215,27 +194,21 @@
% set containing all the elements of `SetA' except those that
% occur in `SetB'.
-:- pred set_ordlist__difference(set_ordlist(T), set_ordlist(T),
- set_ordlist(T)).
-:- mode set_ordlist__difference(in, in, out) is det.
-
+:- pred set_ordlist__difference(set_ordlist(T)::in, set_ordlist(T)::in,
+ set_ordlist(T)::out) is det.
:- func set_ordlist__difference(set_ordlist(T), set_ordlist(T))
= set_ordlist(T).
% `set_ordlist__count(Set, Count)' is true iff `Set' has
% `Count' elements.
-:- pred set_ordlist__count(set_ordlist(T), int).
-:- mode set_ordlist__count(in, out) is det.
-
+:- pred set_ordlist__count(set_ordlist(T)::in, int::out) is det.
:- func set_ordlist__count(set_ordlist(T)) = int.
-
:- func set_ordlist__map(func(T1) = T2, set_ordlist(T1)) = set_ordlist(T2).
:- func set_ordlist__filter_map(func(T1) = T2, set_ordlist(T1))
= set_ordlist(T2).
-
:- mode set_ordlist__filter_map(func(in) = out is semidet, in) = out is det.
:- func set_ordlist__fold(func(T1, T2) = T2, set_ordlist(T1), T2) = T2.
@@ -243,9 +216,9 @@
% set_ordlist__divide(Pred, Set, TruePart, FalsePart):
% TruePart consists of those elements of Set for which Pred succeeds;
% FalsePart consists of those elements of Set for which Pred fails.
-:- pred set_ordlist__divide(pred(T1), set_ordlist(T1), set_ordlist(T1),
- set_ordlist(T1)).
-:- mode set_ordlist__divide(pred(in) is semidet, in, out, out) is det.
+:- pred set_ordlist__divide(pred(T1)::in(pred(in) is semidet),
+ set_ordlist(T1)::in, set_ordlist(T1)::out, set_ordlist(T1)::out)
+ is det.
%--------------------------------------------------------------------------%
@@ -351,8 +324,7 @@
% set_ordlist__sort_no_dups(List, Set) is true iff
% List is a list with the same elements as Set and
% List contains no duplicates.
-:- pred set_ordlist__sort_no_dups(list(T), set_ordlist(T)).
-:- mode set_ordlist__sort_no_dups(in, out) is semidet.
+:- pred set_ordlist__sort_no_dups(list(T)::in, set_ordlist(T)::out) is semidet.
set_ordlist__sort_no_dups(List, Set) :-
list__sort(List, Set),
@@ -388,9 +360,8 @@
set_ordlist__init(Set0),
set_ordlist__power_union_2(SetofSets, Set0, Set).
-:- pred set_ordlist__power_union_2(list(set_ordlist(T)), set_ordlist(T),
- set_ordlist(T)).
-:- mode set_ordlist__power_union_2(in, in, out) is det.
+:- pred set_ordlist__power_union_2(list(set_ordlist(T))::in, set_ordlist(T)::in,
+ set_ordlist(T)::out) is det.
set_ordlist__power_union_2([], Set, Set).
set_ordlist__power_union_2([NextSet|SetofSets], Set0, Set) :-
@@ -519,11 +490,10 @@
list__reverse(RevTruePart, TruePart),
list__reverse(RevFalsePart, FalsePart).
-:- pred set_ordlist__divide_2(pred(T1), set_ordlist(T1),
- set_ordlist(T1), set_ordlist(T1),
- set_ordlist(T1), set_ordlist(T1)).
-:- mode set_ordlist__divide_2(pred(in) is semidet, in, in, out, in, out)
- is det.
+:- pred set_ordlist__divide_2(pred(T1)::in(pred(in) is semidet),
+ set_ordlist(T1)::in,
+ set_ordlist(T1)::in, set_ordlist(T1)::out,
+ set_ordlist(T1)::in, set_ordlist(T1)::out) is det.
set_ordlist__divide_2(_Pred, [], RevTrue, RevTrue, RevFalse, RevFalse).
set_ordlist__divide_2(Pred, [H | T], RevTrue0, RevTrue, RevFalse0, RevFalse) :-
Index: library/set_unordlist.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/library/set_unordlist.m,v
retrieving revision 1.20
diff -u -b -r1.20 set_unordlist.m
--- library/set_unordlist.m 19 Feb 2002 09:25:28 -0000 1.20
+++ library/set_unordlist.m 9 Mar 2004 16:37:08 -0000
@@ -22,31 +22,26 @@
% `set_unordlist__list_to_set(List, Set)' is true iff `Set' is the set
% containing only the members of `List'.
-:- pred set_unordlist__list_to_set(list(T), set_unordlist(T)).
-:- mode set_unordlist__list_to_set(in, out) is det.
-
+:- pred set_unordlist__list_to_set(list(T)::in, set_unordlist(T)::out) is det.
:- func set_unordlist__list_to_set(list(T)) = set_unordlist(T).
+
% `set_unordlist__sorted_list_to_set(List, Set)' is true iff `Set' is
% the set containing only the members of `List'. `List' must be sorted.
-:- pred set_unordlist__sorted_list_to_set(list(T), set_unordlist(T)).
-:- mode set_unordlist__sorted_list_to_set(in, out) is det.
-
+:- pred set_unordlist__sorted_list_to_set(list(T)::in, set_unordlist(T)::out)
+ is det.
:- func set_unordlist__sorted_list_to_set(list(T)) = set_unordlist(T).
% `set_unordlist__to_sorted_list(Set, List)' is true iff `List' is the
% list of all the members of `Set', in sorted order.
-:- pred set_unordlist__to_sorted_list(set_unordlist(T), list(T)).
-:- mode set_unordlist__to_sorted_list(in, out) is det.
-
+:- pred set_unordlist__to_sorted_list(set_unordlist(T)::in, list(T)::out)
+ is det.
:- func set_unordlist__to_sorted_list(set_unordlist(T)) = list(T).
% `set_unordlist__init(Set)' is true iff `Set' is an empty set.
-:- pred set_unordlist__init(set_unordlist(_T)).
-:- mode set_unordlist__init(uo) is det.
-
+:- pred set_unordlist__init(set_unordlist(_T)::uo) is det.
:- func set_unordlist__init = set_unordlist(T).
% `set_unordlist__singleton_set(Set, Elem)' is true iff `Set' is the set
@@ -61,25 +56,24 @@
% `set_unordlist__equal(SetA, SetB)' is true iff
% `SetA' and `SetB' contain the same elements.
-:- pred set_unordlist__equal(set_unordlist(T), set_unordlist(T)).
-:- mode set_unordlist__equal(in, in) is semidet.
+:- pred set_unordlist__equal(set_unordlist(T)::in, set_unordlist(T)::in)
+ is semidet.
% `set_unordlist__empty(Set)' is true iff `Set' is an empty set.
-:- pred set_unordlist__empty(set_unordlist(_T)).
-:- mode set_unordlist__empty(in) is semidet.
+:- pred set_unordlist__empty(set_unordlist(_T)::in) is semidet.
% `set_unordlist__subset(SetA, SetB)' is true iff `SetA' is a subset of
% `SetB'.
-:- pred set_unordlist__subset(set_unordlist(T), set_unordlist(T)).
-:- mode set_unordlist__subset(in, in) is semidet.
+:- pred set_unordlist__subset(set_unordlist(T)::in, set_unordlist(T)::in)
+ is semidet.
% `set_unordlist__superset(SetA, SetB)' is true iff `SetA' is a
% superset of `SetB'.
-:- pred set_unordlist__superset(set_unordlist(T), set_unordlist(T)).
-:- mode set_unordlist__superset(in, in) is semidet.
+:- pred set_unordlist__superset(set_unordlist(T)::in, set_unordlist(T)::in)
+ is semidet.
% `set_unordlist__member(X, Set)' is true iff `X' is a member of `Set'.
@@ -90,14 +84,13 @@
% `set_unordlist__is_member(X, Set, Result)' returns
% `Result = yes' iff `X' is a member of `Set'.
-:- pred set_unordlist__is_member(T, set_unordlist(T), bool).
-:- mode set_unordlist__is_member(in, in, out) is det.
+:- pred set_unordlist__is_member(T::in, set_unordlist(T)::in, bool::out)
+ is det.
% `set_unordlist__contains(Set, X)' is true iff
% `X' is a member of `Set'.
-:- pred set_unordlist__contains(set_unordlist(T), T).
-:- mode set_unordlist__contains(in, in) is semidet.
+:- pred set_unordlist__contains(set_unordlist(T)::in, T::in) is semidet.
% `set_unordlist__insert(Set0, X, Set)' is true iff `Set' is the union
% of `Set0' and the set containing only `X'.
@@ -111,9 +104,8 @@
% `set_unordlist__insert_list(Set0, Xs, Set)' is true iff `Set' is the
% union of `Set0' and the set containing only the members of `Xs'.
-:- pred set_unordlist__insert_list(set_unordlist(T), list(T),
- set_unordlist(T)).
-:- mode set_unordlist__insert_list(in, in, out) is det.
+:- pred set_unordlist__insert_list(set_unordlist(T)::in, list(T)::in,
+ set_unordlist(T)::out) is det.
:- func set_unordlist__insert_list(set_unordlist(T), list(T))
= set_unordlist(T).
@@ -133,9 +125,8 @@
% relative complement of `Set0' and the set containing only the members
% of `Xs'.
-:- pred set_unordlist__delete_list(set_unordlist(T), list(T),
- set_unordlist(T)).
-:- mode set_unordlist__delete_list(in, in, out) is det.
+:- pred set_unordlist__delete_list(set_unordlist(T)::in, list(T)::in,
+ set_unordlist(T)::out) is det.
:- func set_unordlist__delete_list(set_unordlist(T), list(T))
= set_unordlist(T).
@@ -145,32 +136,30 @@
% containing only `X', i.e. if `Set' is the set which contains
% all the elements of `Set0' except `X'.
-:- pred set_unordlist__remove(set_unordlist(T), T, set_unordlist(T)).
-:- mode set_unordlist__remove(in, in, out) is semidet.
+:- pred set_unordlist__remove(set_unordlist(T)::in, T::in,
+ set_unordlist(T)::out) is semidet.
% `set_unordlist__remove_list(Set0, Xs, Set)' is true iff Xs does not
% contain any duplicates, `Set0' contains every member of `Xs',
% and `Set' is the relative complement of `Set0' and the set
% containing only the members of `Xs'.
-:- pred set_unordlist__remove_list(set_unordlist(T), list(T),
- set_unordlist(T)).
-:- mode set_unordlist__remove_list(in, in, out) is semidet.
+:- pred set_unordlist__remove_list(set_unordlist(T)::in, list(T)::in,
+ set_unordlist(T)::out) is semidet.
% `set_unordlist__remove_least(Set0, X, Set)' is true iff `X' is the
% least element in `Set0', and `Set' is the set which contains all the
% elements of `Set0' except `X'.
-:- pred set_unordlist__remove_least(set_unordlist(T), T, set_unordlist(T)).
-:- mode set_unordlist__remove_least(in, out, out) is semidet.
+:- pred set_unordlist__remove_least(set_unordlist(T)::in, T::out,
+ set_unordlist(T)::out) is semidet.
% `set_unordlist_union(SetA, SetB, Set)' is true iff `Set' is the union
% of `SetA' and `SetB'. If the sets are known to be of different
% sizes, then for efficiency make `SetA' the larger of the two.
-:- pred set_unordlist__union(set_unordlist(T), set_unordlist(T),
- set_unordlist(T)).
-:- mode set_unordlist__union(in, in, out) is det.
+:- pred set_unordlist__union(set_unordlist(T)::in, set_unordlist(T)::in,
+ set_unordlist(T)::out) is det.
:- func set_unordlist__union(set_unordlist(T), set_unordlist(T))
= set_unordlist(T).
@@ -178,15 +167,13 @@
% `set_unordlist__union_list(A) = B' is true iff `B' is the union of
% all the sets in `A'
-:- func set_unordlist__union_list(list(set_unordlist(T)))
- = set_unordlist(T).
+:- func set_unordlist__union_list(list(set_unordlist(T))) = set_unordlist(T).
% `set_unordlist__power_union(A, B)' is true iff `B' is the union of
% all the sets in `A'
-:- pred set_unordlist__power_union(set_unordlist(set_unordlist(T)),
- set_unordlist(T)).
-:- mode set_unordlist__power_union(in, out) is det.
+:- pred set_unordlist__power_union(set_unordlist(set_unordlist(T))::in,
+ set_unordlist(T)::out) is det.
:- func set_unordlist__power_union(set_unordlist(set_unordlist(T)))
= set_unordlist(T).
@@ -194,9 +181,8 @@
% `set_unordlist__intersect(SetA, SetB, Set)' is true iff `Set' is the
% intersection of `SetA' and `SetB'.
-:- pred set_unordlist__intersect(set_unordlist(T), set_unordlist(T),
- set_unordlist(T)).
-:- mode set_unordlist__intersect(in, in, out) is det.
+:- pred set_unordlist__intersect(set_unordlist(T)::in, set_unordlist(T)::in,
+ set_unordlist(T)::out) is det.
:- func set_unordlist__intersect(set_unordlist(T), set_unordlist(T))
= set_unordlist(T).
@@ -204,9 +190,8 @@
% `set_unordlist__power_intersect(A, B)' is true iff `B' is the
% intersection of all the sets in `A'
-:- pred set_unordlist__power_intersect(set_unordlist(set_unordlist(T)),
- set_unordlist(T)).
-:- mode set_unordlist__power_intersect(in, out) is det.
+:- pred set_unordlist__power_intersect(set_unordlist(set_unordlist(T))::in,
+ set_unordlist(T)::out) is det.
:- func set_unordlist__power_intersect(set_unordlist(set_unordlist(T)))
= set_unordlist(T).
@@ -221,14 +206,12 @@
% set containing all the elements of `SetA' except those that
% occur in `SetB'
-:- pred set_unordlist__difference(set_unordlist(T), set_unordlist(T),
- set_unordlist(T)).
-:- mode set_unordlist__difference(in, in, out) is det.
+:- pred set_unordlist__difference(set_unordlist(T)::in, set_unordlist(T)::in,
+ set_unordlist(T)::out) is det.
:- func set_unordlist__difference(set_unordlist(T), set_unordlist(T))
= set_unordlist(T).
-
:- func set_unordlist__map(func(T1) = T2, set_unordlist(T1))
= set_unordlist(T2).
@@ -328,9 +311,8 @@
set_unordlist__power_union_2(PS, S0, S1),
list__sort_and_remove_dups(S1, S).
-:- pred set_unordlist__power_union_2(list(set_unordlist(T)), set_unordlist(T),
- set_unordlist(T)).
-:- mode set_unordlist__power_union_2(in, in, out) is det.
+:- pred set_unordlist__power_union_2(list(set_unordlist(T))::in,
+ set_unordlist(T)::in, set_unordlist(T)::out) is det.
set_unordlist__power_union_2([], S, S).
set_unordlist__power_union_2([T|Ts], S0, S) :-
@@ -340,15 +322,12 @@
set_unordlist__intersect(S0, S1, S) :-
set_unordlist__intersect_2(S0, S1, [], S).
-:- pred set_unordlist__intersect_2(set_unordlist(T), set_unordlist(T),
- set_unordlist(T), set_unordlist(T)).
-:- mode set_unordlist__intersect_2(in, in, in, out) is det.
+:- pred set_unordlist__intersect_2(set_unordlist(T)::in, set_unordlist(T)::in,
+ set_unordlist(T)::in, set_unordlist(T)::out) is det.
set_unordlist__intersect_2([], _, S, S).
set_unordlist__intersect_2([E|S0], S1, S2, S) :-
- (
- list__member(E, S1)
- ->
+ ( list__member(E, S1) ->
S3 = [E|S2]
;
S3 = S2
@@ -357,9 +336,7 @@
set_unordlist__power_intersect([], []).
set_unordlist__power_intersect([S0|Ss], S) :-
- (
- Ss = []
- ->
+ ( Ss = [] ->
S = S0
;
set_unordlist__power_intersect(Ss, S1),
@@ -374,9 +351,8 @@
set_unordlist__difference(A, B, C) :-
set_unordlist__difference_2(B, A, C).
-:- pred set_unordlist__difference_2(set_unordlist(T), set_unordlist(T),
- set_unordlist(T)).
-:- mode set_unordlist__difference_2(in, in, out) is det.
+:- pred set_unordlist__difference_2(set_unordlist(T)::in, set_unordlist(T)::in,
+ set_unordlist(T)::out) is det.
set_unordlist__difference_2([], C, C).
set_unordlist__difference_2([E|Es], A, C) :-
@@ -444,11 +420,10 @@
set_unordlist__divide(Pred, Set, RevTruePart, RevFalsePart) :-
set_unordlist__divide_2(Pred, Set, [], RevTruePart, [], RevFalsePart).
-:- pred set_unordlist__divide_2(pred(T1), set_unordlist(T1),
- set_unordlist(T1), set_unordlist(T1),
- set_unordlist(T1), set_unordlist(T1)).
-:- mode set_unordlist__divide_2(pred(in) is semidet, in, in, out, in, out)
- is det.
+:- pred set_unordlist__divide_2(pred(T1)::in(pred(in) is semidet),
+ set_unordlist(T1)::in,
+ set_unordlist(T1)::in, set_unordlist(T1)::out,
+ set_unordlist(T1)::in, set_unordlist(T1)::out) is det.
set_unordlist__divide_2(_Pred, [], RevTrue, RevTrue, RevFalse, RevFalse).
set_unordlist__divide_2(Pred, [H | T],
Index: library/time.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/library/time.m,v
retrieving revision 1.43
diff -u -b -r1.43 time.m
--- library/time.m 12 Mar 2004 03:16:54 -0000 1.43
+++ library/time.m 12 Mar 2004 06:09:23 -0000
@@ -19,8 +19,7 @@
:- interface.
-:- use_module io.
-:- import_module std_util.
+:- import_module io, std_util.
% The `clock_t' type represents times measured in clock ticks.
% NOTE: the unit used for a value of this type depends on whether it was
@@ -31,10 +30,12 @@
% The `tms' type holds information about the amount of processor
% time that a process and its child processes have consumed.
:- type tms --->
- tms(clock_t, % tms_utime: user time
+ tms(
+ clock_t, % tms_utime: user time
clock_t, % tms_stime: system time
clock_t, % tms_cutime: user time of children
- clock_t). % tms_cstime: system time of children
+ clock_t % tms_cstime: system time of children
+ ).
% The `time_t' type is an abstract type that represents
% calendar times.
@@ -45,8 +46,8 @@
% Comparison (via compare/3) of `tm' values whose `tm_dst'
% components are identical is equivalent to comparison of
% the times those `tm' values represent.
-:- type tm
- ---> tm(
+:- type tm --->
+ tm(
tm_year :: int, % Year (number since 1900)
tm_mon :: int, % Month (number since January, 0-11)
tm_mday :: int, % MonthDay (1-31)
@@ -79,8 +80,7 @@
% To obtain a time in seconds, divide Result by
% `time__clocks_per_sec'.
%
-:- pred time__clock(clock_t, io__state, io__state).
-:- mode time__clock(out, di, uo) is det.
+:- pred time__clock(clock_t::out, io::di, io::uo) is det.
% time__clocks_per_sec:
% Returns the number of "clocks" per second as defined by
@@ -96,8 +96,7 @@
% If the time cannot be obtained, this procedure
% will throw a time_error exception.
%
-:- pred time__time(time_t, io__state, io__state).
-:- mode time__time(out, di, uo) is det.
+:- pred time__time(time_t::out, io::di, io::uo) is det.
%-----------------------------------------------------------------------------%
@@ -114,8 +113,7 @@
% On non-POSIX systems that do not support this functionality,
% this procedure may simply always throw an exception.
%
-:- pred time__times(tms, clock_t, io__state, io__state).
-:- mode time__times(out, out, di, uo) is det.
+:- pred time__times(tms::out, clock_t::out, io::di, io::uo) is det.
% time__clk_tck:
% Returns the number of "clock ticks" per second as defined by
@@ -222,6 +220,7 @@
:- pred compare_time_t_reps(comparison_result::uo,
time_t_rep::in, time_t_rep::in) is det.
+
compare_time_t_reps(Result, X, Y) :-
compare(Result, difftime(time_t(X), time_t(Y)), 0.0).
@@ -230,25 +229,26 @@
%:- pred time__clock(clock_t, io__state, io__state).
%:- mode time__clock(out, di, uo) is det.
-time__clock(Result, IO0, IO) :-
- time__c_clock(Ret, IO0, IO),
+time__clock(Result, !IO) :-
+ time__c_clock(Ret, !IO),
( Ret = -1 ->
throw(time_error("can't get clock value"))
;
Result = Ret
).
-:- pred time__c_clock(int, io__state, io__state).
-:- mode time__c_clock(out, di, uo) is det.
+:- pred time__c_clock(int::out, io::di, io::uo) is det.
-:- pragma foreign_proc("C", time__c_clock(Ret::out, IO0::di, IO::uo),
+:- pragma foreign_proc("C",
+ time__c_clock(Ret::out, IO0::di, IO::uo),
[will_not_call_mercury, promise_pure, tabled_for_io],
"{
Ret = (MR_Integer) clock();
MR_update_io(IO0, IO);
}").
/* XXX need to add System.dll to the references list.
-:- pragma foreign_proc("C#", time__c_clock(Ret::out, _IO0::di, _IO::uo),
+:- pragma foreign_proc("C#",
+ time__c_clock(Ret::out, _IO0::di, _IO::uo),
[will_not_call_mercury, promise_pure, tabled_for_io],
"{
// XXX Ticks is long in .NET!
@@ -256,7 +256,8 @@
.UserProcessorTime.Ticks;
}").
*/
-:- pragma foreign_proc("Java", time__c_clock(Ret::out, _IO0::di, _IO::uo),
+:- pragma foreign_proc("Java",
+ time__c_clock(Ret::out, _IO0::di, _IO::uo),
[will_not_call_mercury, promise_pure, tabled_for_io],
"
if (mercury.runtime.Native.isAvailable()) {
@@ -273,18 +274,21 @@
%:- func time__clocks_per_sec = int.
-:- pragma foreign_proc("C", time__clocks_per_sec = (Ret::out),
+:- pragma foreign_proc("C",
+ time__clocks_per_sec = (Ret::out),
[will_not_call_mercury, promise_pure],
"{
Ret = (MR_Integer) CLOCKS_PER_SEC;
}").
-:- pragma foreign_proc("C#", time__clocks_per_sec = (Ret::out),
+:- pragma foreign_proc("C#",
+ time__clocks_per_sec = (Ret::out),
[will_not_call_mercury, promise_pure],
"{
// TicksPerSecond is guaranteed to be 10,000,000
Ret = (int) System.TimeSpan.TicksPerSecond;
}").
-:- pragma foreign_proc("Java", time__clocks_per_sec = (Ret::out),
+:- pragma foreign_proc("Java",
+ time__clocks_per_sec = (Ret::out),
[will_not_call_mercury, promise_pure],
"
if (mercury.runtime.Native.isAvailable()) {
@@ -299,11 +303,8 @@
%-----------------------------------------------------------------------------%
-%:- pred time__times(tms, clock_t, io__state, io__state).
-%:- mode time__times(out, out, di, uo) is det.
-
-time__times(Tms, Result, IO0, IO) :-
- time__c_times(Ret, Ut, St, CUt, CSt, IO0, IO),
+time__times(Tms, Result, !IO) :-
+ time__c_times(Ret, Ut, St, CUt, CSt, !IO),
( Ret = -1 ->
throw(time_error("can't get times value"))
;
@@ -311,12 +312,12 @@
Result = Ret
).
-:- pred time__c_times(int, int, int, int, int, io__state, io__state).
-:- mode time__c_times(out, out, out, out, out, di, uo) is det.
+:- pred time__c_times(int::out, int::out, int::out, int::out, int::out,
+ io::di, io::uo) is det.
:- pragma foreign_proc("C",
- time__c_times(Ret::out, Ut::out, St::out, CUt::out,
- CSt::out, IO0::di, IO::uo),
+ time__c_times(Ret::out, Ut::out, St::out, CUt::out, CSt::out,
+ IO0::di, IO::uo),
[will_not_call_mercury, promise_pure, tabled_for_io],
"{
#ifdef MR_HAVE_POSIX_TIMES
@@ -335,8 +336,8 @@
}").
:- pragma foreign_proc("Java",
- time__c_times(Ret::out, Ut::out, St::out, CUt::out,
- CSt::out, _IO0::di, _IO::uo),
+ time__c_times(Ret::out, Ut::out, St::out, CUt::out, CSt::out,
+ _IO0::di, _IO::uo),
[will_not_call_mercury, promise_pure, tabled_for_io],
"
if (mercury.runtime.Native.isAvailable()) {
@@ -384,13 +385,15 @@
}").
time__c_clk_tck = -1. % default is to throw an exception.
-:- pragma foreign_proc("C#", time__clk_tck = (Ret::out),
+:- pragma foreign_proc("C#",
+ time__clk_tck = (Ret::out),
[will_not_call_mercury, promise_pure],
"{
// TicksPerSecond is guaranteed to be 10,000,000
Ret = (int) System.TimeSpan.TicksPerSecond;
}").
-:- pragma foreign_proc("Java", time__c_clk_tck = (Ret::out),
+:- pragma foreign_proc("Java",
+ time__c_clk_tck = (Ret::out),
[will_not_call_mercury, promise_pure],
"
if (mercury.runtime.Native.isAvailable()) {
@@ -405,19 +408,15 @@
%-----------------------------------------------------------------------------%
-%:- pred time__time(time_t, io__state, io__state).
-%:- mode time__time(out, di, uo) is det.
-
-time__time(Result, IO0, IO) :-
- time__c_time(Ret, IO0, IO),
+time__time(Result, !IO) :-
+ time__c_time(Ret, !IO),
( time__time_t_is_invalid(Ret) ->
throw(time_error("can't get time value"))
;
Result = time_t(Ret)
).
-:- pred time__c_time(time_t_rep, io__state, io__state).
-:- mode time__c_time(out, di, uo) is det.
+:- pred time__c_time(time_t_rep::out, io::di, io::uo) is det.
:- pragma foreign_proc("C",
time__c_time(Ret::out, IO0::di, IO::uo),
@@ -439,8 +438,7 @@
Ret = new java.util.Date();
").
-:- pred time__time_t_is_invalid(time_t_rep).
-:- mode time__time_t_is_invalid(in) is semidet.
+:- pred time__time_t_is_invalid(time_t_rep::in) is semidet.
:- pragma foreign_proc("C",
time__time_t_is_invalid(Val::in),
@@ -461,7 +459,6 @@
succeeded = false;
").
-
%-----------------------------------------------------------------------------%
%:- func time__difftime(time_t, time_t) = float.
@@ -469,8 +466,7 @@
time__difftime(time_t(T1), time_t(T0)) = Diff :-
time__c_difftime(T1, T0, Diff).
-:- pred time__c_difftime(time_t_rep, time_t_rep, float).
-:- mode time__c_difftime(in, in, out) is det.
+:- pred time__c_difftime(time_t_rep::in, time_t_rep::in, float::out) is det.
:- pragma foreign_proc("C",
time__c_difftime(T1::in, T0::in, Diff::out),
@@ -495,16 +491,12 @@
%-----------------------------------------------------------------------------%
-%:- func time__localtime(time_t) = tm.
-
time__localtime(time_t(Time)) = TM :-
time__c_localtime(Time, Yr, Mnt, MD, Hrs, Min, Sec, YD, WD, N),
TM = tm(Yr, Mnt, MD, Hrs, Min, Sec, YD, WD, int_to_maybe_dst(N)).
-:- pred time__c_localtime(time_t_rep, int, int, int, int, int, int,
- int, int, int).
-:- mode time__c_localtime(in, out, out, out, out, out, out,
- out, out, out) is det.
+:- pred time__c_localtime(time_t_rep::in, int::out, int::out, int::out,
+ int::out, int::out, int::out, int::out, int::out, int::out) is det.
:- pragma foreign_proc("C",
time__c_localtime(Time::in, Yr::out, Mnt::out, MD::out, Hrs::out,
@@ -605,8 +597,7 @@
} else {
N = 0;
}
-"). % time__c_local_time
-
+").
%:- func time__gmtime(time_t) = tm.
@@ -614,10 +605,8 @@
time__c_gmtime(Time, Yr, Mnt, MD, Hrs, Min, Sec, YD, WD, N),
TM = tm(Yr, Mnt, MD, Hrs, Min, Sec, YD, WD, int_to_maybe_dst(N)).
-:- pred time__c_gmtime(time_t_rep, int, int, int, int, int,
- int, int, int, int).
-:- mode time__c_gmtime(in, out, out, out, out, out,
- out, out, out, out) is det.
+:- pred time__c_gmtime(time_t_rep::in, int::out, int::out, int::out, int::out,
+ int::out, int::out, int::out, int::out, int::out) is det.
:- pragma foreign_proc("C",
time__c_gmtime(Time::in, Yr::out, Mnt::out, MD::out, Hrs::out,
@@ -708,7 +697,7 @@
}
N = 0;
-"). % time__c_gmtime
+").
:- func int_to_maybe_dst(int) = maybe(dst).
@@ -730,8 +719,8 @@
time__c_mktime(Yr, Mnt, MD, Hrs, Min, Sec, YD, WD,
maybe_dst_to_int(DST), Time).
-:- pred time__c_mktime(int, int, int, int, int, int, int, int, int, time_t_rep).
-:- mode time__c_mktime(in, in, in, in, in, in, in, in, in, out) is det.
+:- pred time__c_mktime(int::in, int::in, int::in, int::in, int::in, int::in,
+ int::in, int::in, int::in, time_t_rep::out) is det.
:- pragma foreign_proc("C",
time__c_mktime(Yr::in, Mnt::in, MD::in, Hrs::in, Min::in, Sec::in,
@@ -907,7 +896,6 @@
mon_name(10, "Nov").
mon_name(11, "Dec").
-
%-----------------------------------------------------------------------------%
%:- func time__ctime(time_t) = string.
@@ -919,12 +907,15 @@
% XXX This needs to be in the interface because pragma export doesn't work yet
% on the .NET backend and io.m needs to access this.
:- interface.
+
:- type time_t_rep.
+
:- func construct_time_t(time_t_rep) = time_t.
+
:- implementation.
+
:- pragma export(construct_time_t(in) = out, "ML_construct_time_t").
+
construct_time_t(T) = time_t(T).
-%-----------------------------------------------------------------------------%
-:- end_module time.
%-----------------------------------------------------------------------------%
Index: library/type_desc.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/library/type_desc.m,v
retrieving revision 1.25
diff -u -b -r1.25 type_desc.m
--- library/type_desc.m 1 Mar 2004 00:23:31 -0000 1.25
+++ library/type_desc.m 9 Mar 2004 15:02:56 -0000
@@ -522,7 +522,8 @@
} else {
MR_TypeCtorInfo type_ctor_info;
- type_ctor_info = MR_TYPECTOR_DESC_GET_FIXED_ARITY_TYPE_CTOR_INFO(
+ type_ctor_info =
+ MR_TYPECTOR_DESC_GET_FIXED_ARITY_TYPE_CTOR_INFO(
type_ctor_desc);
/*
cvs diff: Diffing profiler
cvs diff: Diffing robdd
cvs diff: Diffing runtime
cvs diff: Diffing runtime/GETOPT
cvs diff: Diffing runtime/machdeps
cvs diff: Diffing samples
cvs diff: Diffing samples/c_interface
cvs diff: Diffing samples/c_interface/c_calls_mercury
cvs diff: Diffing samples/c_interface/cplusplus_calls_mercury
cvs diff: Diffing samples/c_interface/mercury_calls_c
cvs diff: Diffing samples/c_interface/mercury_calls_cplusplus
cvs diff: Diffing samples/c_interface/mercury_calls_fortran
cvs diff: Diffing samples/c_interface/simpler_c_calls_mercury
cvs diff: Diffing samples/c_interface/simpler_cplusplus_calls_mercury
cvs diff: Diffing samples/diff
cvs diff: Diffing samples/muz
cvs diff: Diffing samples/rot13
cvs diff: Diffing samples/solutions
cvs diff: Diffing samples/tests
cvs diff: Diffing samples/tests/c_interface
cvs diff: Diffing samples/tests/c_interface/c_calls_mercury
cvs diff: Diffing samples/tests/c_interface/cplusplus_calls_mercury
cvs diff: Diffing samples/tests/c_interface/mercury_calls_c
cvs diff: Diffing samples/tests/c_interface/mercury_calls_cplusplus
cvs diff: Diffing samples/tests/c_interface/mercury_calls_fortran
cvs diff: Diffing samples/tests/c_interface/simpler_c_calls_mercury
cvs diff: Diffing samples/tests/c_interface/simpler_cplusplus_calls_mercury
cvs diff: Diffing samples/tests/diff
cvs diff: Diffing samples/tests/muz
cvs diff: Diffing samples/tests/rot13
cvs diff: Diffing samples/tests/solutions
cvs diff: Diffing samples/tests/toplevel
cvs diff: Diffing scripts
cvs diff: Diffing tests
cvs diff: Diffing tests/benchmarks
cvs diff: Diffing tests/debugger
cvs diff: Diffing tests/debugger/declarative
cvs diff: Diffing tests/dppd
cvs diff: Diffing tests/general
cvs diff: Diffing tests/general/accumulator
cvs diff: Diffing tests/general/string_format
cvs diff: Diffing tests/general/structure_reuse
cvs diff: Diffing tests/grade_subdirs
cvs diff: Diffing tests/hard_coded
cvs diff: Diffing tests/hard_coded/exceptions
cvs diff: Diffing tests/hard_coded/purity
cvs diff: Diffing tests/hard_coded/sub-modules
cvs diff: Diffing tests/hard_coded/typeclasses
cvs diff: Diffing tests/invalid
cvs diff: Diffing tests/invalid/purity
cvs diff: Diffing tests/misc_tests
cvs diff: Diffing tests/mmc_make
cvs diff: Diffing tests/mmc_make/lib
cvs diff: Diffing tests/recompilation
cvs diff: Diffing tests/tabling
cvs diff: Diffing tests/term
cvs diff: Diffing tests/valid
cvs diff: Diffing tests/warnings
cvs diff: Diffing tools
cvs diff: Diffing trace
cvs diff: Diffing util
cvs diff: Diffing vim
cvs diff: Diffing vim/after
cvs diff: Diffing vim/ftplugin
cvs diff: Diffing vim/syntax
--------------------------------------------------------------------------
mercury-reviews mailing list
post: mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------
More information about the reviews
mailing list