[m-rev.] Additions to list.m

Fergus Henderson fjh at cs.mu.OZ.AU
Thu Dec 13 17:28:00 AEDT 2001


On 13-Dec-2001, Ralph Becket <rafe at cs.mu.OZ.AU> wrote:
> Additions to list.m.

The new functions should be noted in the NEWS file.

> Index: list.m
> ===================================================================
> RCS file: /home/mercury1/repository/mercury/library/list.m,v
> retrieving revision 1.100
> diff -u -r1.100 list.m
> --- list.m	24 Aug 2001 08:44:08 -0000	1.100
> +++ list.m	13 Dec 2001 04:54:30 -0000
> @@ -441,6 +441,21 @@
>  	is nondet.
>  :- mode list__map3(pred(in, in, in, in) is semidet, in, in, in, in) is semidet.
>  
> +	% list__map_corresponding(F, [A1, .. An], [B1, .. Bn]) =
> +	% 	[F(A1, B1), .., F(An, Bn)].

s/../.../
s/..,/.../

> @@ -450,6 +465,7 @@
>  :- mode list__foldl(pred(in, in, out) is det, in, in, out) is det.
>  :- mode list__foldl(pred(in, in, out) is semidet, in, in, out) is semidet.
>  :- mode list__foldl(pred(in, in, out) is nondet, in, in, out) is nondet.
> +:- mode list__foldl(pred(in, di, uo) is cc_multi, in, di, uo) is cc_multi.

If you're going to add that mode, I think it would make sense to also add

   :- mode list__foldl(pred(in, in, out) is cc_multi, in, in, out) is cc_multi.

> +:- mode list__foldr(pred(in, di, uo) is cc_multi, in, di, uo) is cc_multi.

Likewise.

> @@ -659,7 +676,7 @@
>  
>  :- implementation.
>  
> -:- import_module bintree_set, require, std_util.
> +:- import_module bintree_set, require, std_util, exception.

That shouldn't be needed...

> +list__map_corresponding3(F, As, Bs, Cs) =
> +	( if      As = [A | As0], Bs = [B | Bs0], Cs = [C | Cs0] then
> +		[F(A, B, C) | list__map_corresponding3(F, As0, Bs0, Cs0)]
> +	  else if As = [],        Bs = [],        Cs = []        then
> +	  	[]
> +	  else
> +	  	throw(software_error(
> +			"list__map_corresponding3: mismatched list arguments"))
> +	).

... because here you should just use error/1 rather than
throw(software_error(...)).

Otherwise that looks fine.

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
The University of Melbourne         |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
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