[m-rev.] Additions to queue.m

Julien Fischer juliensf at cs.mu.OZ.AU
Tue Jan 25 14:16:43 AEDT 2005


> Index: library/queue.m
> ===================================================================
> RCS file: /home/mercury1/repository/mercury/library/queue.m,v
> retrieving revision 1.26
> diff -u -r1.26 queue.m
> --- library/queue.m	24 Jan 2005 23:16:38 -0000	1.26
> +++ library/queue.m	25 Jan 2005 02:43:27 -0000
> @@ -88,6 +88,10 @@
>  	%
>  :- func queue__from_list(list(T)) = queue(T).
>
> +	% `queue__to_list(Queue) = List' is the inverse of queue__from_list/1.
> +	%
> +:- func queue__to_list(queue(T)) = list(T).
> +
>  	% `queue__delete_all(Queue0, Elem, Queue)' is true iff `Queue' is
>  	% the same queue as `Queue0' with all occurrences of `Elem' removed
>  	% from it.
> @@ -95,6 +99,25 @@
>  :- pred queue__delete_all(queue(T)::in, T::in, queue(T)::out) is det.
>  :- func queue__delete_all(queue(T), T) = queue(T).
>
> +	% `queue__put_on_front(Queue0, Elem, Queue)' pushes `Elem' on to
> +	% the front of `Queue0', giving `Queue'.
> +	%
> +:- pred queue__put_on_front(queue(T)::in, T::in, queue(T)::out) is det.

I'd switch the order of the arguments here so that it's more state
variable friendly (and below as well).

> +:- func queue__put_on_front(queue(T), T) = queue(T).
> +
> +	% `queue__put_list_on_front(Queue0, Elems, Queue)' pushes `Elems'
> +	% on to the front of `Queue0', giving `Queue' (the Nth member
> +	% of `Elems' becomes the Nth member from the front of `Queue').
> +	%
> +:- pred queue__put_list_on_front(queue(T)::in, list(T)::in, queue(T)::out)
> +	is det.
> +:- func queue__put_list_on_front(queue(T), list(T)) = queue(T).
> +
> +	% `queue__get_from_back(Queue0, Elem, Queue)' removes `Elem' from
> +	% the back of `Queue0', giving `Queue'.
> +	%
> +:- pred queue__get_from_back(queue(T)::in, T::out, queue(T)::out) is semidet.
> +

Cheers,
Julien.
--------------------------------------------------------------------------
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