Stack: Difference between revisions

639 bytes added ,  4 years ago
Add Genie
(Add Genie)
Line 2,371:
3 2 1
</pre>
 
=={{header|Genie}}==
<lang genie>[indent=4]
/*
Stack, in Genie, with GLib double ended Queues
valac stack.gs
*/
init
var stack = new Queue of int()
 
// push
stack.push_tail(2)
stack.push_tail(1)
 
// pop (and peek at top)
print stack.pop_tail().to_string()
print stack.peek_tail().to_string()
 
// empty
print "stack size before clear: " + stack.get_length().to_string()
stack.clear()
print "After clear, stack.is_empty(): " + stack.is_empty().to_string()</lang>
 
{{out}}
<pre>prompt$ valac stack.gs
prompt$ ./stack
1
2
stack size before clear: 1
After clear, stack.is_empty(): true</pre>
 
=={{header|Go}}==
Go slices make excellent stacks without defining any extra types, functions, or methods. For example, to keep a stack of integers, simply declare one as,
Anonymous user