Queue/Definition: Difference between revisions

→‎Icon and Unicon: removed - moved to usage as push/pop are builtin
(→‎Icon and Unicon: removed - moved to usage as push/pop are builtin)
Line 834:
isEmpty _ = False
</lang>
 
== Icon and Unicon ==
==={{header|Icon}}===
Icon and Unicon provide built-in queue and stack functions.
<lang Icon>procedure main(arglist)
queue := []
write("Usage:\nqueue x x x - x - - - - -\n- pops elements\neverything else pushes")
write("Queue is:")
every x := !arglist do {
case x of {
"-" : pop(queue) | write("pop(empty) failed.) # pop if the next arglist[i] is a -
default : push(queue,x) # push arglist[i]
}
if empty(queue) then writes("empty")
else every writes(!queue," ")
write()
}
end
 
procedure empty(X) #: fail if X is not empty
if *X = 0 then return
end</lang>
 
==={{header|Unicon}}===
This Icon solution works in Unicon.
 
 
=={{header|J}}==
Anonymous user