17 lines
793 B
Text
17 lines
793 B
Text
def \Node\ Link, Data; \linked list element definition
|
|
int Node, List, N;
|
|
def IntSize = 4; \number of bytes in an integer
|
|
[List:= 0; \List is initially empty
|
|
for N:= 1 to 10 do \build linked list, starting at the end
|
|
[Node:= Reserve(IntSize*2); \get some memory to store Link and Data
|
|
Node(Link):= List;
|
|
Node(Data):= N*N; \insert example data
|
|
List:= Node; \List now points to newly created node
|
|
];
|
|
Node:= List; \traverse the linked list
|
|
while Node # 0 do
|
|
[IntOut(0, Node(Data)); \display the example data
|
|
ChOut(0, ^ );
|
|
Node:= Node(Link); \move to next node
|
|
];
|
|
]
|