Stack: Difference between revisions

473 bytes added ,  18 days ago
PascalABC.NET
(PascalABC.NET)
 
(One intermediate revision by one other user not shown)
Line 3,546:
 
Of course, these stack semantics are not ''exclusive''. Elements of the list can still be accessed and manipulated in myriads of other ways.
 
If you need exclusive stack semantics, you can use the <code>java.util.Stack</code> class, as demonstrated in the [[Stack#Java|Java]] example.
 
<syntaxhighlight lang="groovy">def stack = []
assert stack.empty
Line 5,323 ⟶ 5,326:
dispose(node);
end;</syntaxhighlight>
 
=={{header|PascalABC.NET}}==
<syntaxhighlight lang="delphi">
begin
var st := new Stack<integer>;
var st1 := new Stack<integer>;
st.Push(1);
st.Push(2);
st.Push(3);
Println(st1,st);
while st.Count <> 0 do
st1.Push(st.Pop);
Println(st1,st);
end.
</syntaxhighlight>
{{out}}
<pre>
[] [3,2,1]
[1,2,3] []
</pre>
 
 
=={{header|Perl}}==
218

edits