How to resolve the algorithm Doubly-linked list/Traversal step by step in the Oberon-2 programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Doubly-linked list/Traversal step by step in the Oberon-2 programming language
Table of Contents
Problem Statement
Traverse from the beginning of a doubly-linked list to the end, and from the end to the beginning.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Doubly-linked list/Traversal step by step in the Oberon-2 programming language
Source code in the oberon-2 programming language
MODULE Collections;
IMPORT Box;
TYPE
Action = PROCEDURE (o: Box.Object);
PROCEDURE (dll: DLList) GoForth*(do: Action);
VAR
iter: Node;
BEGIN
iter := dll.first;
WHILE iter # NIL DO
do(iter.value);
iter := iter.next
END
END GoForth;
PROCEDURE (dll: DLList) GoBack*(do: Action);
VAR
iter: Node;
BEGIN
ASSERT(dll.last # NIL);
iter := dll.last;
WHILE iter # NIL DO
do(iter.value);
iter := iter.prev
END
END GoBack;
END Collections.
You may also check:How to resolve the algorithm Loops/Break step by step in the HolyC programming language
You may also check:How to resolve the algorithm Mertens function step by step in the Go programming language
You may also check:How to resolve the algorithm Input loop step by step in the PicoLisp programming language
You may also check:How to resolve the algorithm Sylvester's sequence step by step in the J programming language
You may also check:How to resolve the algorithm Take notes on the command line step by step in the M2000 Interpreter programming language