[m-rev.] trivial for review: added set.size

Ondrej Bojar obo at cuni.cz
Mon Feb 5 21:33:09 AEDT 2007


(Sorry if a second copy arrives, my mail queue is sort of stuck again.)

The change seems so small that I'm not adding a message to NEWS. Should I?

Estimated hours taken: 0

Added size function the the set module and the underlying set_ordlist
representation.

library/set.m:
     Added set.size/1 function.

library/set_ordlist.m:
     Added set_ordlist.size/1 function

Index: library/set.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/library/set.m,v
retrieving revision 1.80
diff -u -r1.80 set.m
--- library/set.m	1 Dec 2006 15:04:37 -0000	1.80
+++ library/set.m	5 Feb 2007 05:46:37 -0000
@@ -77,6 +77,9 @@

  :- pred set.non_empty(set(T)::in) is semidet.

+    % `set.size(Set)' returns the number of elements in Set.
+:- func set.size(set(T)) = int.
+
      % `set.subset(SetA, SetB)' is true iff `SetA' is a subset of `SetB'.
      %
  :- pred set.subset(set(T)::in, set(T)::in) is semidet.
@@ -380,6 +383,8 @@
  set.non_empty(Set) :-
      \+ set_ordlist.empty(Set).

+set.size(Set) = set_ordlist.size(Set).
+
  set.subset(SetA, SetB) :-
      set_ordlist.subset(SetA, SetB).

Index: library/set_ordlist.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/library/set_ordlist.m,v
retrieving revision 1.29
diff -u -r1.29 set_ordlist.m
--- library/set_ordlist.m	30 Oct 2006 01:24:04 -0000	1.29
+++ library/set_ordlist.m	5 Feb 2007 05:49:52 -0000
@@ -76,6 +76,9 @@
      %
  :- pred set_ordlist.empty(set_ordlist(_T)::in) is semidet.

+    % `set_ordlist.size(Set)' returns the number of elements in Set.
+:- func set_ordlist.size(set_ordlist(T)) = int.
+
      % `set_ordlist.subset(SetA, SetB)' is true iff `SetA' is a subset of
      % `SetB'.
      %
@@ -320,6 +323,8 @@

  set_ordlist.empty([]).

+set_ordlist.size(S) = list.length(S).
+
  set_ordlist.subset(Subset, Set) :-
      set_ordlist.intersect(Set, Subset, Subset).



-- 
Ondrej Bojar (mailto:obo at cuni.cz)
http://www.cuni.cz/~obo
--------------------------------------------------------------------------
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