[m-dev.] sorted_list_to_set
Mark Brown
mark at cs.mu.OZ.AU
Wed Feb 8 15:07:35 AEDT 2006
Hi,
The predicate set.sorted_list_to_set has the following documentation and
implementation:
% `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.
%
:- pred set__sorted_list_to_set(list(T)::in, set(T)::out) is det.
set__sorted_list_to_set(List, Set) :-
set_ordlist__sorted_list_to_set(List, Set).
Note that the list can't contain duplicates. OTOH, the predicate
set_ordlist.sorted_list_to_set has:
% `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)::in,
set_ordlist(T)::out) is det.
set_ordlist__sorted_list_to_set(List0, List) :-
list__remove_adjacent_dups(List0, List).
It doesn't have the assumption that there are no duplicates, and therefore it
can't make use of that fact.
At the very least, the terminology is not consistent. More importantly, I
want to be able to convert a known ordered-no-dups list into a set as
efficiently as possible. Are there any strong objections to changing the
meaning of the latter so that it makes that assuption? The change would
not be backwards compatible.
Cheers,
Mark.
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to: mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions: mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------
More information about the developers
mailing list