Created
October 7, 2008 12:04
-
-
Save be9/15281 to your computer and use it in GitHub Desktop.
Modula-2 lists
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MODULE struc; | |
IMPORT SWholeIO; | |
FROM Storage IMPORT ALLOCATE, DEALLOCATE; | |
TYPE | |
PNode = POINTER TO Node; | |
Node = RECORD | |
number : CARDINAL; | |
next : PNode; | |
END; | |
VAR n1, n2, p: PNode; | |
BEGIN | |
NEW(n1); | |
NEW(n2); | |
n1^.number := 10; | |
n2^.number := 20; | |
n1^.next := n2; | |
n2^.next := NIL; | |
p := n1; | |
WHILE p <> NIL DO | |
SWholeIO.WriteCard(p^.number, 5); | |
p := p^.next; | |
END; | |
DISPOSE(n1); | |
DISPOSE(n2); | |
END struc. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment