Doubly-linked list/Traversal: Difference between revisions

PascalABC.NET
m (syntax highlighting fixup automation)
(PascalABC.NET)
 
(2 intermediate revisions by 2 users not shown)
Line 1,982:
=={{header|Pascal}}==
See [[Doubly-linked_list/Traversal#Delphi | Delphi]]
 
=={{header|PascalABC.NET}}==
<syntaxhighlight lang="delphi">
begin
var lst := new LinkedList<integer>(1..10);
var current := lst.First;
while current <> nil do
begin
Print(current.Value);
current := current.Next;
end;
end.
</syntaxhighlight>
{{out}}
<pre>
1 2 3 4 5 6 7 8 9 10
</pre>
 
 
=={{header|Phix}}==
Line 2,553 ⟶ 2,571:
{{libheader|Wren-llist}}
{{libheader|Wren-fmt}}
<syntaxhighlight lang="ecmascriptwren">import "./llist" for DLinkedList
import "./fmt" for Fmt
 
// create a new doubly-linked list and add the first 50 positive integers to it
Line 2,584 ⟶ 2,602:
20 19 18 17 16 15 14 13 12 11
10 9 8 7 6 5 4 3 2 1
</pre>
 
=={{header|XPL0}}==
<syntaxhighlight lang "XPL0">def \Node\ Prev, Data, Next; \Element (Node) definition
def SizeofInt = 4;
 
proc Insert(NewNode, Node); \Insert NewNode after Node
int NewNode, Node, NextNode;
[NextNode:= Node(Next);
NextNode(Prev):= NewNode;
NewNode(Next):= NextNode;
NewNode(Prev):= Node;
Node(Next):= NewNode;
];
 
int Head(3), Tail(3); \Doubly linked list definition
int N, NewNode, Node;
[\Further define (initialize) the doubly linked list
Head(Next):= Tail;
Tail(Prev):= Head;
\Insert some Nodes containing square data
for N:= 1 to 10 do
[NewNode:= Reserve(3*SizeofInt);
NewNode(Data):= N*N;
Insert(NewNode, Head);
];
\Traverse list from Head to Tail
Node:= Head(Next);
while Node # Tail do
[IntOut(0, Node(Data)); ChOut(0, ^ );
Node:= Node(Next);
];
CrLf(0);
\Traverse list from Tail to Head
Node:= Tail(Prev);
while Node # Head do
[IntOut(0, Node(Data)); ChOut(0, ^ );
Node:= Node(Prev);
];
CrLf(0);
]</syntaxhighlight>
{{out}}
<pre>
100 81 64 49 36 25 16 9 4 1
1 4 9 16 25 36 49 64 81 100
</pre>
 
246

edits