[m-rev.] proposed changes to set modules in stdlib

Julien Fischer juliensf at csse.unimelb.edu.au
Tue Nov 9 00:59:09 AEDT 2010


Hi,

Based on Peter's table here is a set of proposed changes to the various
set modules in the stdlib with the aim of unifying their interfaces.

We can probably get away with breaking backwards compatibility
for all of them except for set.m / svset.m (so I've done that).

Also, where there are predicate and function versions of an operation
I've only retained the predicate version where it is useful with
state variables.

Julien.


> ---
> ct=set_ctree234, t=set_tree234, s=set, sv=svset, ol=set_ordlist,
> ul=set_unordlist, bb=set_bbbtree
>
> pred init(S):                               s   ol  ul  bb
> func init = S:                      ct  t   s   ol  ul  bb

Delete the predicate version in ol, ul, bb.
Deprecate the predicate version in s.

> pred singleton_set(T,S):            ct  t
> pred singleton_set(S,T):                    s   ol  ul  bb
> func make_singleton_set(T) = S:     ct  t   s   ol  ul  bb

Deprecate the predicate versions in s; delete it in the others.

> pred non_empty(S):                          s

Add non_empty/1 for the others.

> pred is_member(X,S,b):                      s   ol  ul  bb
> pred is_member(S,X,b):              ct  t
> func is_member(S,X) = b:            ct  t

Deprecate the predicate versions in s; delete it in the others.

> pred list_to_set([T], S):                   s   ol  ul  bb
> func list_to_set([T]) = S:          ct  t   s   ol  ul  bb

Delete the predicate version in ol, ul, bb.
Deprecate the predicate version in s.

> func from_list([T]) = S:                    s   ol  ul

Add this to the other modules.

> pred sorted_list_to_set([T], S):            s   ol  ul  bb
> func sorted_list_to_set([T]) = S:   ct  t   s   ol  ul  bb

Deprecate the predicate versions in s; delete it in the others.

> func from_sorted_list([T]) = S:             s   ol  ul  bb

Add to ct and t.

> pred to_sorted_list(S, [T]):                s   ol  ul  bb
> func to_sorted_list(S) = [T]:       ct  t   s   ol  ul  bb

Deprecate the predicate versions.

> pred insert(S,T,S):                         s   ol  ul  bb
> func insert(S,T) = S:                       s   ol  ul  bb
> pred insert(T,S,S):                 ct  t   sv
> func insert(T,S) = S:               ct  t

It's the latter forms we want, (1) change the ol, ul and bb
defns now.  (We can swap s around when it's time to get rid
of sv.)

> pred insert_list(S,[T],S):                  s   ol  ul  bb
> func insert_list(S,[T]) = S:                s   ol  ul  bb
> pred insert_list([T],S,S):          ct  t   sv
> func insert_list([T],S) = S:        ct  t

Likewise here.

> pred delete(S,T,S):                         s   ol  ul  bb
> func delete(S,T) = S:                       s   ol  ul  bb
> pred delete(T,S,S):                 ct  t   sv
> func delete(T,S) = S:               ct  t

And here.

> pred delete_list(S,[T],S):                  s   ol  ul  bb
> func delete_list(S,[T]) = S:                s   ol  ul  bb
> pred delete_list([T],S,S):          ct  t   sv
> func delete_list([T],S) = S:        ct  t

And here.

> pred remove(S,T,S):                         s   ol  ul  bb
> pred remove(T,S,S):                 ct  t   sv

Change ol, ul, and bb to the second form.

> pred remove_list(S,[T],S):                  s   ol  ul  bb
> pred remove_list([T],S,S):          ct  t   sv

Likewise.

> pred remove_least(S,T,S):                   s   ol  ul  bb
> pred remove_least(T,S,S):           ct  t   sv

Likewise.

> pred remove_largest(S,T,S):                             bb

Change the argument ordering; it's not clear that this operation
is particularly useful since we've got by without it in any
of the other set implementations.

> pred union_list([S],S):             ct  t
> func union_list([S]) = S:           ct  t   s   ol  ul  bb

Delete the predicate versions.

> pred power_intersect(S(S), S):              s   ol  ul  bb
> func power_intersect(S(S)) = S:     ct  t   s   ol  ul  bb

Delete the predicate version for ol, ul, bb.
Deprecate the predicate version for s.

> pred count(S, int):                         s   ol
> func count(S) = int:                ct  t   s   ol
> pred size(S, int):                                      bb

Deprecate the predicate version of count.
Deprecate set_bbbtree.size/2.
Add the function set_bbbtree.count/1.

> pred divide(P,S,S,S):               ct  t   s   ol  ul
> pred divide_by_set(S,S,S,S):        ct  t   s   ol

Provide these for the other modules.
--------------------------------------------------------------------------
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