Queue/Usage: Difference between revisions

added Arturo
m (BBC BASIC moved to the BASIC section.)
(added Arturo)
Line 421:
(*1*)
</pre>
 
=={{header|Arturo}}==
 
<syntaxhighlight lang="arturo">define :queue [][
init: [
this\items: []
]
]
 
empty?: function [this :queue][
zero? this\items
]
 
push: function [this :queue, item][
this\items: this\items ++ item
]
 
pop: function [this :queue][
ensure -> not? empty? this
result: this\items\0
this\items: remove.index this\items 0
return result
]
 
Q: to :queue []
 
push Q 1
push Q 2
push Q 3
 
print ["queue is empty?" empty? Q]
 
print ["popping:" pop Q]
print ["popping:" pop Q]
print ["popping:" pop Q]
 
print ["queue is empty?" empty? Q]</syntaxhighlight>
 
{{out}}
 
<pre>queue is empty? false
popping: 1
popping: 2
popping: 3
queue is empty? true</pre>
 
=={{header|Astro}}==
1,532

edits