Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
35
Task/Queue-Usage/Arturo/queue-usage.arturo
Normal file
35
Task/Queue-Usage/Arturo/queue-usage.arturo
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
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]
|
||||
Loading…
Add table
Add a link
Reference in a new issue