Skip to content

Instantly share code, notes, and snippets.

@be9
Created October 7, 2008 12:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save be9/15281 to your computer and use it in GitHub Desktop.
Save be9/15281 to your computer and use it in GitHub Desktop.
Modula-2 lists
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