[m-rev.] diff: add is_empty/1 for all set modules in stdlib
Julien Fischer
juliensf at csse.unimelb.edu.au
Tue May 10 15:25:43 AEST 2011
Branches: main
Add predicates named is_empty/1 as a synonym for empty/1 to all the modules in
the standard library that provide sets. The former name is less ambiguous than
the latter.
library/set*.m:
library/spare_bitset.m:
library/tree_bitset.m:
Add is_empty/1 as a synonym for empty/1.
NEWS:
Announce the above addition.
Julien.
Index: NEWS
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/NEWS,v
retrieving revision 1.568
diff -u -r1.568 NEWS
--- NEWS 10 May 2011 04:12:23 -0000 1.568
+++ NEWS 10 May 2011 05:20:28 -0000
@@ -107,6 +107,13 @@
* The deprecated modules graph, group and relation are no longer included
in the library.
+* The following predicates have been added to the modules that provide sets
+ in the library: set.is_empty/1, set_bbbtree.is_empty/1,
+ set_ctree234.is_empty/1, set_ordlist.is_empty/1, set_tree234.is_empty/1,
+ set_unordlist.is_empty/1, sparse_bitset.is_empty/1, tree_bitset.is_empty/1.
+
+ All are synonyms for the existing empty/1 predicates in those modules.
+
NEWS for Mercury 11.01
----------------------
Index: library/set.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/library/set.m,v
retrieving revision 1.91
diff -u -r1.91 set.m
--- library/set.m 6 May 2011 05:03:28 -0000 1.91
+++ library/set.m 10 May 2011 04:57:25 -0000
@@ -79,6 +79,11 @@
:- pred set.non_empty(set(T)::in) is semidet.
+ % A synonym for set.empty/1.
+ %
+:- pred set.is_empty(set(T)::in) is semidet.
+
+
% `set.subset(SetA, SetB)' is true iff `SetA' is a subset of `SetB'.
%
:- pred set.subset(set(T)::in, set(T)::in) is semidet.
@@ -463,6 +468,9 @@
set.empty(Set) :-
set_ordlist.empty(Set).
+set.is_empty(Set) :-
+ set_ordlist.empty(Set).
+
set.non_empty(Set) :-
\+ set_ordlist.empty(Set).
Index: library/set_bbbtree.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/library/set_bbbtree.m,v
retrieving revision 1.36
diff -u -r1.36 set_bbbtree.m
--- library/set_bbbtree.m 6 May 2011 05:34:01 -0000 1.36
+++ library/set_bbbtree.m 10 May 2011 05:01:50 -0000
@@ -34,6 +34,10 @@
%
:- pred set_bbbtree.empty(set_bbbtree(T)::in) is semidet.
+ % A synonym for the above.
+ %
+:- pred set_bbbtree.is_empty(set_bbbtree(T)::in) is semidet.
+
:- pred set_bbbtree.non_empty(set_bbbtree(T)::in) is semidet.
% `set_bbbtree.count(Set, Count)' is true iff `Set' has `Count' elements.
@@ -444,6 +448,8 @@
set_bbbtree.empty(empty).
+set_bbbtree.is_empty(empty).
+
set_bbbtree.non_empty(tree(_, _, _, _)).
%------------------------------------------------------------------------------%
Index: library/set_ctree234.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/library/set_ctree234.m,v
retrieving revision 1.14
diff -u -r1.14 set_ctree234.m
--- library/set_ctree234.m 30 Nov 2010 02:41:53 -0000 1.14
+++ library/set_ctree234.m 10 May 2011 05:04:47 -0000
@@ -50,6 +50,8 @@
%
:- pred set_ctree234.empty(set_ctree234(_T)::in) is semidet.
+:- pred set_ctree234.is_empty(set_ctree234(_T)::in) is semidet.
+
:- pred set_ctree234.non_empty(set_ctree234(T)::in) is semidet.
% `set_ctree234.member(X, Set)' is true iff `X' is a member of `Set'.
@@ -420,6 +422,8 @@
set_ctree234.empty(ct(0, _)).
+set_ctree234.is_empty(ct(0, _)).
+
set_ctree234.non_empty(ct(N, _)) :- N \= 0.
:- pragma promise_equivalent_clauses(set_ctree234.member/2).
Index: library/set_ordlist.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/library/set_ordlist.m,v
retrieving revision 1.36
diff -u -r1.36 set_ordlist.m
--- library/set_ordlist.m 30 Nov 2010 02:41:53 -0000 1.36
+++ library/set_ordlist.m 10 May 2011 04:58:27 -0000
@@ -78,6 +78,8 @@
:- pred set_ordlist.non_empty(set_ordlist(T)::in) is semidet.
+:- pred set_ordlist.is_empty(set_ordlist(T)::in) is semidet.
+
% `set_ordlist.subset(SetA, SetB)' is true iff `SetA' is a subset of
% `SetB'.
%
@@ -438,6 +440,8 @@
set_ordlist.non_empty(sol([_ | _])).
+set_ordlist.is_empty(sol([])).
+
set_ordlist.subset(Subset, Set) :-
set_ordlist.intersect(Set, Subset, Subset).
Index: library/set_tree234.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/library/set_tree234.m,v
retrieving revision 1.16
diff -u -r1.16 set_tree234.m
--- library/set_tree234.m 30 Nov 2010 02:41:53 -0000 1.16
+++ library/set_tree234.m 10 May 2011 05:05:36 -0000
@@ -42,6 +42,10 @@
%
:- pred set_tree234.empty(set_tree234(_T)::in) is semidet.
+ % A synonym for the above.
+ %
+:- pred set_tree234.is_empty(set_tree234(_T)::in) is semidet.
+
:- pred set_tree234.non_empty(set_tree234(T)::in) is semidet.
% `set_tree234.member(X, Set)' is true iff `X' is a member of `Set'.
@@ -402,6 +406,8 @@
set_tree234.empty(empty).
+set_tree234.is_empty(empty).
+
set_tree234.non_empty(two(_, _, _)).
set_tree234.non_empty(three(_, _, _, _, _)).
set_tree234.non_empty(four(_, _, _, _, _, _, _)).
Index: library/set_unordlist.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/library/set_unordlist.m,v
retrieving revision 1.33
diff -u -r1.33 set_unordlist.m
--- library/set_unordlist.m 16 Feb 2011 02:11:50 -0000 1.33
+++ library/set_unordlist.m 10 May 2011 05:00:55 -0000
@@ -80,6 +80,8 @@
:- pred set_unordlist.non_empty(set_unordlist(_T)::in) is semidet.
+:- pred set_unordlist.is_empty(set_unordlist(_T)::in) is semidet.
+
% `set_unordlist.subset(SetA, SetB)' is true iff `SetA' is a subset of
% `SetB'.
%
@@ -390,6 +392,8 @@
set_unordlist.empty(sul([])).
+set_unordlist.is_empty(sul([])).
+
set_unordlist.non_empty(sul([_ | _])).
set_unordlist.subset(sul([]), _).
Index: library/sparse_bitset.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/library/sparse_bitset.m,v
retrieving revision 1.36
diff -u -r1.36 sparse_bitset.m
--- library/sparse_bitset.m 21 Mar 2007 22:30:27 -0000 1.36
+++ library/sparse_bitset.m 10 May 2011 05:09:24 -0000
@@ -62,6 +62,8 @@
:- mode empty(in) is semidet.
:- mode empty(out) is det.
+:- pred is_empty(sparse_bitset(T)::in) is semidet.
+
% `equal(SetA, SetB' is true iff `SetA' and `SetB' contain the same
% elements. Takes O(min(rep_size(SetA), rep_size(SetB))) time.
%
@@ -411,6 +413,8 @@
equal(X, X).
+is_empty(sparse_bitset([])).
+
%-----------------------------------------------------------------------------%
to_sorted_list(Set) = foldr(func(Elem, Acc0) = [Elem | Acc0], Set, []).
Index: library/tree_bitset.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/library/tree_bitset.m,v
retrieving revision 1.6
diff -u -r1.6 tree_bitset.m
--- library/tree_bitset.m 1 Nov 2010 05:45:06 -0000 1.6
+++ library/tree_bitset.m 10 May 2011 05:10:12 -0000
@@ -54,6 +54,8 @@
:- mode empty(in) is semidet.
:- mode empty(out) is det.
+:- pred is_empty(tree_bitset(T)::in) is semidet.
+
% `equal(SetA, SetB)' is true iff `SetA' and `SetB' contain the same
% elements. Takes O(min(card(SetA), card(SetB))) time.
%
@@ -851,6 +853,8 @@
empty(init).
+is_empty(init).
+
equal(SetA, SetB) :-
trace [compile_time(flag("tree-bitset-integrity"))] (
(
--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to: mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions: mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------
More information about the reviews
mailing list