Stack: Difference between revisions

155 bytes added ,  2 months ago
m
(Added Easylang)
(3 intermediate revisions by 3 users not shown)
Line 2,600:
.
func pop .
iflng = len stack[] = 0
if lng = 0
return 0
.
r = stack[-1lng]
len stack[] -1
return r
Line 2,695 ⟶ 2,696:
var stack := new system'collections'Stack();
stack.push:(2);
var isEmpty := stack.Length == 0;
Line 3,545 ⟶ 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 7,069 ⟶ 7,073:
{{libheader|Wren-seq}}
This uses the Stack class in the above module.
<syntaxhighlight lang="ecmascriptwren">import "./seq" for Stack
 
var s = Stack.new()
1

edit