Queue/Usage: Difference between revisions

no edit summary
No edit summary
Line 164:
---
END
 
=={{header|Arturo}}==
 
<lang arturo>Queue #{
list #()
 
push {
list list+&
}
 
pop {
if $(empty) {
panic "trying to pop from an empty queue!"
}
 
first_item $(first list)
list $(deleteBy list 0)
return first_item
}
 
empty {
$(size list)=0
}
 
inspect {
log this
}
}
 
q $(new ~Queue)
 
q.push "one"
q.push "two"
q.push "three"
 
q.inspect
 
print "popped = " + $(q.pop)
print "is it empty? = " + $(q.empty)</lang>
 
{{out}}
 
<pre>#{
empty <function: 0x1093917A0>
inspect <function: 0x109391800>
list #(
"one"
"two"
"three"
)
pop <function: 0x109391740>
push <function: 0x1093916E0>
}
popped = one
is it empty? = false</pre>
 
=={{header|Astro}}==
1,532

edits