pull
- command to facilitate the use of a list as a queue
- new in 1.59
- The pull command can then be used to retrieve values from the beginning of a list. To use a list as a FIFO (first in, first out) queue, push values onto end of the queue and then pull them from the front of the queue in the same order that they were added:
set waitingList to an empty list
push "A" onto waitingList
push "B" onto waitingList
pull from waitingList into x -- x is now "A"
pull from waitingList into y -- y is now "B"
The pull command can also be used to obtain values from the middle of a list, from a nested list, or to obtain multiple values at once. If a destination container is not specified, values removed from the list are put into it:
set source to "a".."z"
pull item 14 of source into x -- x is now "n"
pull (A,B,C) into item 13 of source -- item 13 is now (m,A,B,C)
pull from nested item 13 of source -- sets IT to C, item 13 to (m,A,B)
pull the last three items of source into tail -- tail is now (x,y,z)
pull items (2,5,1,4) of source into z -- z is now (b,e,a,d)
- Related: push, pop, insert