[m-rev.] diff/for review: add set.from_list/1 and set.from_sorted_list/1

Julien Fischer juliensf at cs.mu.OZ.AU
Sun Jan 16 03:59:11 AEDT 2005


Estimated hours taken: 0.5
Branches: main

Add functions set.from_list/1 and set.from_sorted_list/1
as synonyms for set.list_to_set/1 and set.sorted_list_to_set/1
respectively.  The names of the new versions are more consistent
in style with the rest of the standard library.

Make a similar change to the other set_* modules.

library/set.m:
library/set_unordlist.m:
library/set_ordlist.m:
library/set_bbbtree.m:
	Add functions from_list/1 and from_sorted_list/1 as
	synonyms for list_to_set/1 and sorted_list_to_set/1.

NEWS:
	Mention the additions.

Julien.

Workspace:/home/saskervoy/juliensf/ws58
Index: NEWS
===================================================================
RCS file: /home/mercury1/repository/mercury/NEWS,v
retrieving revision 1.362
diff -u -r1.362 NEWS
--- NEWS	14 Jan 2005 06:04:16 -0000	1.362
+++ NEWS	15 Jan 2005 16:35:55 -0000
@@ -126,6 +126,11 @@

 Changes to the Mercury standard library:

+* We've added functions set.from_list/1 and set.from_sorted_list/1
+  as synonyms for set.list_to_set/1 and set.sorted_list_to_set/1
+  respectively.  Similar additions have also been made to the
+  set_unordlist, set_ordlist and set_bbbtree modules.
+
 * We've added some new higher-order predicates, rbtree.foldl2/6
   rbtree.foldl3 and rbtree.transform_value to the rbtree module.  The
   predicate rbtree.remove/3 has been deprecated.
Index: library/set.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/set.m,v
retrieving revision 1.64
diff -u -r1.64 set.m
--- library/set.m	10 Jan 2005 05:23:46 -0000	1.64
+++ library/set.m	15 Jan 2005 16:37:50 -0000
@@ -26,6 +26,10 @@
 :- pred set__list_to_set(list(T)::in, set(T)::out) is det.
 :- func set__list_to_set(list(T)) = set(T).

+	% A synonym for set.list_to_set/1.
+	%
+:- func set__from_list(list(T)) = set(T).
+
 	% `set__sorted_list_to_set(List, Set)' is true iff `Set' is the set
 	% containing only the members of `List'.  `List' must be sorted
 	% and must not contain any duplicates.
@@ -33,6 +37,10 @@
 :- pred set__sorted_list_to_set(list(T)::in, set(T)::out) is det.
 :- func set__sorted_list_to_set(list(T)) = set(T).

+	% A synonym for set.sorted_list_to_set/1.
+	%
+:- func set__from_sorted_list(list(T)) = set(T).
+
 	% `set__to_sorted_list(Set, List)' is true iff `List' is the list
 	% of all the members of `Set', in sorted order without any
 	% duplicates.
@@ -304,9 +312,13 @@
 set__list_to_set(List, Set) :-
 	set_ordlist__list_to_set(List, Set).

+set__from_list(List) = set_ordlist__from_list(List).
+
 set__sorted_list_to_set(List, Set) :-
 	set_ordlist__sorted_list_to_set(List, Set).

+set__from_sorted_list(List) = set_ordlist__from_sorted_list(List).
+
 set__to_sorted_list(Set, List) :-
 	set_ordlist__to_sorted_list(Set, List).

Index: library/set_bbbtree.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/set_bbbtree.m,v
retrieving revision 1.21
diff -u -r1.21 set_bbbtree.m
--- library/set_bbbtree.m	15 Mar 2004 23:49:35 -0000	1.21
+++ library/set_bbbtree.m	15 Jan 2005 13:01:52 -0000
@@ -155,6 +155,10 @@

 :- func set_bbbtree__list_to_set(list(T)) = set_bbbtree(T).

+	% A synonym for set_bbtree.list_to_set/1.
+	%
+:- func set_bbbtree__from_list(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).
@@ -164,6 +168,10 @@

 :- func set_bbbtree__sorted_list_to_set(list(T)) = set_bbbtree(T).

+	% A synonym for set_bbbtree.sorted_list_to_set/1.
+	%
+:- func set_bbbtree__from_sorted_list(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
@@ -573,6 +581,9 @@
 	set_bbbtree__init(InitSet),
 	set_bbbtree__insert_list_r(InitSet, List, Set, Ratio).

+set_bbbtree__from_list(List) = Set :-
+	set_bbbtree__list_to_set(List, Set).
+
 %------------------------------------------------------------------------------%

 % The tree is created by first determining it's length. All lists of length
@@ -656,6 +667,9 @@
 		Set = empty
 	).

+set_bbbtree__from_sorted_list(List) = Set :-
+	set_bbbtree__sorted_list_to_set(List, Set).
+
 %------------------------------------------------------------------------------%

 	% Flatten the tree by an accumulator based tree traversal
Index: library/set_ordlist.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/set_ordlist.m,v
retrieving revision 1.18
diff -u -r1.18 set_ordlist.m
--- library/set_ordlist.m	13 Jan 2005 02:41:59 -0000	1.18
+++ library/set_ordlist.m	15 Jan 2005 11:23:39 -0000
@@ -25,6 +25,10 @@
 :- 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).

+	% A synonym for set_ordlist.list_to_set/1.
+	%
+:- func set_ordlist__from_list(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.

@@ -32,6 +36,10 @@
 	is det.
 :- func set_ordlist__sorted_list_to_set(list(T)) = set_ordlist(T).

+	% A synonym for set_ordrlist.sorted_list_to_set/1.
+	%
+:- func set_ordlist__from_sorted_list(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.

@@ -265,9 +273,15 @@
 set_ordlist__list_to_set(List0, List) :-
 	list__sort_and_remove_dups(List0, List).

+set_ordlist__from_list(List0) = List :-
+	set_ordlist__list_to_set(List0, List).
+
 set_ordlist__sorted_list_to_set(List0, List) :-
 	list__remove_adjacent_dups(List0, List).

+set_ordlist__from_sorted_list(List0) = List :-
+	set_ordlist__sorted_list_to_set(List0, List).
+
 set_ordlist__to_sorted_list(List, List).

 set_ordlist__insert_list(Set0, List0, Set) :-
Index: library/set_unordlist.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/set_unordlist.m,v
retrieving revision 1.21
diff -u -r1.21 set_unordlist.m
--- library/set_unordlist.m	15 Mar 2004 23:49:35 -0000	1.21
+++ library/set_unordlist.m	15 Jan 2005 11:25:58 -0000
@@ -25,6 +25,10 @@
 :- 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).

+	% A synonym for set_unordlist.list_to_set/1.
+	%
+:- func set_unordlist__from_list(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.

@@ -32,6 +36,10 @@
 	is det.
 :- func set_unordlist__sorted_list_to_set(list(T)) = set_unordlist(T).

+	% A synonym for set_unordlist.sorted_list_to_set/1.
+	%
+:- func set_unordlist__from_sorted_list(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.

@@ -238,8 +246,12 @@

 set_unordlist__list_to_set(List, List).

+set_unordlist__from_list(List) = List.
+
 set_unordlist__sorted_list_to_set(List, List).

+set_unordlist__from_sorted_list(List) = List.
+
 set_unordlist__to_sorted_list(Set, List) :-
 	list__sort_and_remove_dups(Set, List).


--------------------------------------------------------------------------
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