[m-rev.] For review: Introduce stack.mamber/2 to standard library.
Paul Bone
pbone at csse.unimelb.edu.au
Wed Oct 15 18:04:01 AEDT 2008
For review by anyone.
Estimated Hours taken: 0.2
Branches: main
Introduce stack.member(Elem, Stack), which is true of Elem is somewhere
within the stack Stack.
library/stack.m:
As above'
NEWS:
Announce the change.
Index: NEWS
===================================================================
RCS file: /home/mercury1/repository/mercury/NEWS,v
retrieving revision 1.497
diff -u -p -b -r1.497 NEWS
--- NEWS 23 Sep 2008 06:42:24 -0000 1.497
+++ NEWS 11 Oct 2008 07:02:09 -0000
@@ -122,6 +122,9 @@ Changes to the Mercury standard library:
* We have changed the interface of the ops module to make lookups of operators
more efficient.
+* The following predicates have been added to the stack module:
+ stack.member/2
+
* We have added io.update_globals/3 which allows for atomic updates to
the globals field in the I/O state in the presence of multiple threads.
Index: library/stack.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/stack.m,v
retrieving revision 1.26
diff -u -p -b -r1.26 stack.m
--- library/stack.m 2 Jun 2008 04:55:00 -0000 1.26
+++ library/stack.m 11 Oct 2008 06:58:21 -0000
@@ -82,6 +82,10 @@
:- pred stack.depth(stack(T)::in, int::out) is det.
:- func stack.depth(stack(T)) = int.
+ % 'stack.member(Elem, Stack)' is true iff 'Elem' is contained in the stack.
+ %
+:- pred stack.member(T::in, stack(T)::in) is semidet.
+
%--------------------------------------------------------------------------%
%--------------------------------------------------------------------------%
@@ -135,6 +139,9 @@ stack.det_pop(Stack0, Elem, Stack) :-
stack.depth(stack(Elems), Depth) :-
list.length(Elems, Depth).
+stack.member(Elem, stack(List)) :-
+ list.member(Elem, List).
+
%--------------------------------------------------------------------------%
%--------------------------------------------------------------------------%
% Ralph Becket <rwab1 at cl.cam.ac.uk> 29/04/99
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mercurylang.org/archives/reviews/attachments/20081015/7841495a/attachment.sig>
More information about the reviews
mailing list