previous | index | next

Simulating list Display

To display a list pointed to by lst as Scheme would:
  void displayList(list lst) {
      cout << endl << "(";
      while ( lst != NULL ) {
          cout << lst->item; 
          lst = lst->rest;   
          cout << ( lst == NULL  ? ")" : " " );
      }                                        
      cout << endl;
  }

previous | index | next