trivial diffs to stack.m and portray.nl

Zoltan Somogyi zs at cs.mu.OZ.AU
Tue Jun 23 17:01:31 AEST 1998


Since Peter will force everyone to recompile everything when he checks in
his changes to the library, here are some more trivial changes that can be
done at the same time.

library/portray.nl:
	Fix some formatting.

library/stack.m:
	Add a deterministic version of stack_top.

Zoltan.

cvs diff: Diffing .
Index: portray.nl
===================================================================
RCS file: /home/mercury1/repository/mercury/library/portray.nl,v
retrieving revision 1.18
diff -u -u -r1.18 portray.nl
--- portray.nl	1998/03/27 12:33:56	1.18
+++ portray.nl	1998/05/16 08:24:29
@@ -639,7 +639,7 @@
 	(   N >= 32, N =< 126 -> true
 	;   N =:= 0'\n -> true
 	;   N =:= 0'\r -> true
-	;	N =:= 0'\t
+	;   N =:= 0'\t
 	),
 	printable_char_list(Ns).
 	
Index: stack.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/stack.m,v
retrieving revision 1.14
diff -u -u -r1.14 stack.m
--- stack.m	1998/01/23 12:33:35	1.14
+++ stack.m	1998/02/27 02:25:25
@@ -57,6 +57,12 @@
 :- pred stack__top(stack(T), T).
 :- mode stack__top(in, out) is semidet.
 
+	% `stack__top_det' is like `stack__top' except that it will
+	% call error/1 rather than failing if given an empty stack.
+
+:- pred stack__top_det(stack(T), T).
+:- mode stack__top_det(in, out) is det.
+
 	% `stack__pop(Stack0, Elem, Stack)' is true iff `Stack0' is
 	% a non-empty stack whose top element is `Elem', and `Stack'
 	% the stack which results from popping `Elem' off `Stack0'.
@@ -100,6 +106,13 @@
 	stack__push_list(Stack2, Elems, Stack1).
 
 stack__top([Elem | _], Elem).
+
+stack__top_det(Stack, Elem) :-
+	( Stack = [Elem1 | _] ->
+		Elem = Elem1
+	;
+		error("stack__top_det: top of empty stack")
+	).
 
 stack__pop([Elem | Stack], Elem, Stack).
 



More information about the developers mailing list