[m-rev.] diff: new funcs and preds in the bag module
Julien Fischer
juliensf at csse.unimelb.edu.au
Mon Mar 12 19:25:16 AEDT 2007
On Fri, 9 Mar 2007, Ondrej Bojar wrote:
> Estimated hours taken: 1
> Branch: main
>
> Add functions bag.count/1, bag.count_unique/1 and predicates bag.member/2
> and bag.member/3 to the bag module.
>
> NEWS:
> Announce the new predicates and functions.
> Minor indentation unification.
s/unification/fixes/
> library/bag.m:
> New functions and predicates.
>
> tests/hard_coded/bag_various.m:
> tests/hard_coded/bag_various.exp:
> A simple testcase for the new predicates, with expected results.
>
> tests/hard_coded/Mmakefile:
> Enabled the test.
>
> Index: NEWS
> ===================================================================
> RCS file: /home/mercury/mercury1/repository/mercury/NEWS,v
> retrieving revision 1.450
> diff -u -r1.450 NEWS
> --- NEWS 6 Mar 2007 04:22:37 -0000 1.450
> +++ NEWS 8 Mar 2007 23:13:11 -0000
> @@ -48,11 +48,17 @@
> determinism multi.
>
> * The following functions have been added to the string module:
> - string.split_at_separator/2
> - string.split_at_char/2
> - string.split_at_string/2
> + string.split_at_separator/2
> + string.split_at_char/2
> + string.split_at_string/2
> string.remove_suffix_if_present/2
>
> +* The following functions and predicates have been added to the bag module:
> + bag.count/1
> + bag.count_unique/1
> + bag.member/2
> + bag.member/3
> +
> * We have changed the interface of the ops module to make lookups of
> operators
> more efficient.
>
> Index: library/bag.m
> ===================================================================
> RCS file: /home/mercury/mercury1/repository/mercury/library/bag.m,v
> retrieving revision 1.31
> diff -u -r1.31 bag.m
> --- library/bag.m 23 Oct 2006 00:32:55 -0000 1.31
> +++ library/bag.m 8 Mar 2007 23:13:11 -0000
> @@ -31,6 +31,15 @@
> :- pred bag.init(bag(T)::out) is det.
> :- func bag.init = bag(T).
>
> + % Return the number of values in a bag (including duplicate values).
> + %
> +:- func bag.count(bag(T)) = int.
> +
> + % Return the number of unique values in a bag, duplicate values are
> counted
> + % only once.
> + %
> +:- func bag.count_unique(bag(T)) = int.
> +
> % Insert a particular value in a bag.
> %
> :- pred bag.insert(bag(T)::in, T::in, bag(T)::out) is det.
> @@ -46,6 +55,18 @@
> :- pred bag.insert_set(bag(T)::in, set(T)::in, bag(T)::out) is det.
> :- func bag.insert_set(bag(T), set(T)) = bag(T).
>
> + % bag.member(Val, Bag) :
> + % True iff `Bag' contains at least one occurrence of `Val'.
> + %
> +:- pred bag.member(T::in, bag(T)::in) is semidet.
> +
> + % bag.member(Val, Bag, Remainder) :
s/) :/):/
`
> + % Nondeterministically returns all values from Bag and the
> + % corresponding bag after the value has been removed. Duplicate values
> + % are returned as many times as they occur in the Bag.
> + %
I suggest making the first setence something like:
Nondeterministically returns all values from `Bag'. `Remainder'
is `Bag' after `Val' has been removed.
The rest looks fine.
Julien.
--------------------------------------------------------------------------
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