Traverse from the beginning of a singly-linked list to the end.



See also

 Array
 Associative array: Creation, Iteration
 Collections
 Compound data type
 Doubly-linked list: Definition, Element definition, Element insertion, List Traversal, Element Removal
 Linked list
 Queue: Definition, Usage
 Set
 Singly-linked list: Element definition, Element insertion, List Traversal, Element Removal
 Stack


      DIM node{pNext%, iData%}
      DIM a{} = node{}, b{} = node{}, c{} = node{}
 
      a.pNext% = b{}
      a.iData% = 123
      b.iData% = 789
      c.iData% = 456
 
      PROCinsert(a{}, c{})
 
      PRINT "Traverse list:"
      pnode% = a{}
      REPEAT
        !(^node{}+4) = pnode%
        PRINT node.iData%
        pnode% = node.pNext%
      UNTIL pnode% = 0
 
      END
 
      DEF PROCinsert(here{}, new{})
      new.pNext% = here.pNext%
      here.pNext% = new{}
      ENDPROC
 