home *** CD-ROM | disk | FTP | other *** search
-
- FUNCTION cons(new_node,list : node_ptr) : node_ptr ;
- VAR
- p : node_ptr ;
- BEGIN
- get_memory(p) ;
- p^.tag := cons_node ;
- p^.head_ptr := new_node ;
- p^.tail_ptr := list ;
- cons := p ;
- END ; (* cons *)
-
- FUNCTION head(list : node_ptr) : node_ptr ;
- BEGIN
- IF list = NIL
- THEN head := NIL
- ELSE head := list^.head_ptr ;
- END ; (* head *)
-
- FUNCTION tail(list : node_ptr) : node_ptr ;
- BEGIN
- IF list = NIL
- THEN tail := NIL
- ELSE IF list^.tag = cons_node
- THEN tail := list^.tail_ptr
- ELSE tail := NIL ;
- END ; (* tail *)
-
- Figure 4 - Basic list processing routines.