Node: Iteration Constructs, Next: , Previous: Iteration, Up: Iteration



Iteration Constructs

dolist el list Macro

This macro loops through the Lpp list list with a given variable name el bound to the elements of the list. The variable name el will be bound to the last element of the list on exit from the loop or else nil if the list list was empty. For example the following function would print the given list1 entries in a single column

     void printListColumn(list1) {
       dolist(e, list1) cout << e << endl;}
     

dolist2 el1 list1 el2 list2 Macro

This macro loops through the Lpp lists list1 and list2 with variable names el1 and el2 bound to the elements of the two lists. The variable names el1 and el2 will be bound to the last element processed from the list on exit from the loop or else nil if the list list was empty. If the lists are not the same length the shorter of the two lists terminates the loop.