Queue/Usage: Difference between revisions

Content deleted Content added
Line 32:
Sample output:
<pre>Is_Empty TRUE</pre>
 
 
=={{header|AppleScript}}==
<lang AppleScript >on push(StackRef, value)
set StackRef's contents to {value} & StackRef's contents
return StackRef
end push
 
on pop(StackRef)
set R to missing value
if StackRef's contents ≠ {} then
set R to StackRef's contents's item 1
set StackRef's contents to {} & rest of StackRef's contents
end if
return R
end pop
 
on isEmpty(StackRef)
if StackRef's contents = {} then return true
return false
end isEmpty
 
 
set theStack to {}
repeat with i from 1 to 5
log push(a reference to theStack, i)
end repeat
repeat until isEmpty(theStack) = true
log pop(a reference to theStack)
end repeat</lang>Output:<pre> (*1*)
(*2, 1*)
(*3, 2, 1*)
(*4, 3, 2, 1*)
(*5, 4, 3, 2, 1*)
(*5*)
(*4*)
(*3*)
(*2*)
(*1*)</pre>
 
=={{header|AutoHotkey}}==