Search Top Index
HELP NEXTLOOP R. Barrett et al, 1984, A.Sloman 1986 nextloop(<optional integer>) In a looping construct, NEXTLOOP causes control to jump to just before the syntax word closing the loop, for example ENDWHILE in a WHILE loop, and ENDFOR in a FOR loop. This causes the enclosing loop to be restarted. If an integer N is given, the N'th enclosing loop is 'continued'. The integer defaults to 1 if not supplied. For example, given a vector of ordered lists of integers, find the list with the smallest even integer. define is_even(n); isinteger(n) and n rem 2 == 0 enddefine; define search_smallest_even(vector_of_lists)->smallest; ;;; return the smallest even integer lvars vector_of_lists, smallest=999999999999999999999, index,list,item; for index from 1 to datalength(vector_of_lists) do subscrv(index,vector_of_lists) -> list; for item in list do if is_even(item) and item < smallest then item -> smallest; [found ^item - start next list] => nextloop(2) ;;;CONTINUE 2nd enclosing loop endif; endfor endfor enddefine; search_smallest_even({[ 1 3 7 88 502] [3 7 40 73] [5 8 20 99]}) => ** [found 88 - start next list] ** [found 40 - start next list] ** [found 8 - start next list] ** 8 If NEXTLOOP is followed by an integer, N, the Nth enclosing loop is re-started. N.B: NEXTLOOP is not a procedure and cannot be called by a procedure inside the loop: it must be used in the loop body itself. Moreover, the integer cannot be represented by a variable or an expression evaluating to an integer. (This effect can be achieved using * GO_ON.) See also HELP *QUITLOOP - to jump out of one or more enclosing loops *QUITIF - to jump out of a loop if a condition becomes true *QUITUNLESS - to jump out of a loop if a condition becomes false *NEXTIF - to restart a loop if a condition becomes true *NEXTUNLESS - to restart a loop if a condition becomes false *LOOPS - for types of iteration available in POP-11 *CONTROL - for control structures available in POP-11 REF * SYNTAX - for more on syntactic constructs in POP-11 -----<Copyright University of Sussex 1986. All rights reserved.>-------