|
<< Click to Display Table of Contents >> Navigation: 3. Script Language > Arrays and Data-Structures > ARS. - Array's > !ARS. - Deque Operations > ARS. - Deque Operations |
MiniRobotLanguage (MRL)
ARS.PopLast
Pop the last element from the Deque and return its value.
Intention
The ARS.PopLast command removes the last element from the Deque and returns its value. This is useful for processing elements in a last-in-first-out (LIFO) manner.
Illustration:
Deque Structure:
┌───────────────┐
│ FirstElement │
├───────────────┤
│ SecondElement │
├───────────────┤
│ LastElement │ ← Popped
└───────────────┘
The last element is removed and returned.
Syntax
ARS.PopLast|$$ARR[|$$VAL]
Parameter Explanation
P1 - $$ARR The handle of the Deque.
P2 - $$VAL (optional) The variable to store the popped element. If omitted, the value is placed on the Top of Stack (TOS).
Example
'***********************************
' ARS.PopLast - Sample Script
'***********************************
' Create a new Deque
ARS.New|$$DEQ
' Push elements onto the Deque
ARS.PushFirst|$$DEQ|FirstElement
ARS.PushLast|$$DEQ|LastElement
' Pop the last element
ARS.PopLast|$$DEQ|$$RES
DBP.The popped element is: $$RES
' End the script
ENR.
Remarks
-
Limitations:
- The Deque must not be empty when using this command.
See also:
• ARS.New