Data update
This commit is contained in:
parent
5150844a7d
commit
4bb20c9b71
7735 changed files with 38060 additions and 199180 deletions
|
|
@ -1,35 +1,37 @@
|
|||
define :queue [][
|
||||
init: [
|
||||
define :queue [
|
||||
init: method [][
|
||||
this\items: []
|
||||
]
|
||||
]
|
||||
|
||||
empty?: function [this :queue][
|
||||
zero? this\items
|
||||
]
|
||||
empty?: method [][
|
||||
zero? this\items
|
||||
]
|
||||
|
||||
push: function [this :queue, item][
|
||||
this\items: this\items ++ item
|
||||
]
|
||||
push: method [item][
|
||||
this\items: this\items ++ item
|
||||
]
|
||||
|
||||
pop: function [this :queue][
|
||||
ensure -> not? empty? this
|
||||
pop: method [][
|
||||
ensure [not? this\empty?]
|
||||
|
||||
result: this\items\0
|
||||
this\items: remove.index this\items 0
|
||||
return result
|
||||
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
|
||||
do ::
|
||||
|
||||
print ["queue is empty?" empty? Q]
|
||||
Q\push 1
|
||||
Q\push 2
|
||||
Q\push 3
|
||||
|
||||
print ["popping:" pop Q]
|
||||
print ["popping:" pop Q]
|
||||
print ["popping:" pop Q]
|
||||
print ["queue is empty?" Q\empty?]
|
||||
|
||||
print ["queue is empty?" empty? Q]
|
||||
print ["popping:" Q\pop]
|
||||
print ["popping:" Q\pop]
|
||||
print ["popping:" Q\pop]
|
||||
|
||||
print ["queue is empty?" Q\empty?]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue