|
<< 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.PeekLast
Peek at the last element of the Deque without removing it.
Intention
The ARS.PeekLast command allows you to view the last element of the Deque without removing it. This is useful for inspecting the element at the end of the Deque without altering its contents.
Illustration:
Deque Structure:
┌───────────────┐
│ FirstElement │
├───────────────┤
│ SecondElement │
├───────────────┤
│ LastElement │ ← Peeked
└───────────────┘
The last element is inspected but remains in the Deque.
Syntax
ARS.PeekLast|$$ARR[|$$VAL]
Parameter Explanation
P1 - $$ARR The handle of the Deque.
P2 - $$VAL (optional) The variable to store the last element of the Deque. If omitted, the value is placed on the Top of Stack (TOS).
Example
'***********************************
' ARS.PeekLast - Sample Script
'***********************************
' Create a new Deque
ARS.New|$$DEQ
' Push elements onto the Deque
ARS.PushFirst|$$DEQ|FirstElement
ARS.PushLast|$$DEQ|LastElement
' Peek at the last element
ARS.PeekLast|$$DEQ|$$RES
DBP.The last element is: $$RES
' End the script
ENR.
Remarks
-
Limitations:
- The Deque must not be empty when using this command.
See also:
• ARS.New