Queue/Usage: Difference between revisions
m
→{{header|EasyLang}}
m (BBC BASIC moved to the BASIC section.) |
|||
(6 intermediate revisions by 4 users not shown) | |||
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}}==
Line 1,135 ⟶ 1,181:
E also has queues in the standard library such as <code><import:org.erights.e.examples.concurrency.makeQueue></code>, but they are designed for concurrency purposes and do not report emptiness but rather return a promise for the next element.
=={{header|EasyLang}}==
Uses the queue-definition given at [[Queue/Definition#EasyLang]]
<syntaxhighlight>
#
# queue definition
#
##
qu_enq 2
qu_enq 5
qu_enq 7
while qu_empty = 0
print qu_deq
.
</syntaxhighlight>
=={{header|Elena}}==
ELENA
<syntaxhighlight lang="elena">import system'collections;
import extensions;
Line 1,146 ⟶ 1,207:
var queue := new Queue();
queue.push
queue.push
queue.push
// "Pop" items from the queue in FIFO order
Line 1,160 ⟶ 1,221:
// If we try to pop from an empty queue, an exception
// is thrown.
queue.pop()
}</syntaxhighlight>
Line 3,062 ⟶ 3,123:
=={{header|Wren}}==
{{libheader|Wren-queue}}
<syntaxhighlight lang="
var q = Queue.new()
|