Stack: Difference between revisions
m
→{{header|Groovy}}
(Added Easylang) |
|||
(3 intermediate revisions by 3 users not shown) | |||
Line 2,600:
.
func pop .
if lng = 0
return 0
.
r = stack[
len stack[] -1
return r
Line 2,695 ⟶ 2,696:
var stack := new system'collections'Stack();
stack.push
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="
var s = Stack.new()
|