XEROX UTILISOPRS 2 4 1 UtilISOprs 1 4 By: Tom Lipkis (Lipkis@USC-ISIB) INTRODUCTION This package contains some useful CLISP iterative statement operators contributed by various people over the years. Both upper and lower case versions are recognized. I. S. TYPES COLLECTWHEN form [I.S. Operator] Collects all non-NIL instances of form into a list and returns it as the value of the i.s. when it terminates. INTERSECT form [I.S. Operator] Computes the intersection (using the function INTERSECTION) of all instances of form and returns it as the value of the i.s. form should evaluate to a list (or NIL) on each iteration. UNION form [I.S. Operator] Similar to INTERSECT, but computes the union (using UNION) of all instances of form. FINTERSECT form [I.S. Operator] Similar to INTERSECT, but the intersection is computed using an EQ test rather than EQUAL. Uses the function FIntersection (also defined in this package). FUNION form [I.S. Operator] Similar to UNION, but uses EQ instead of EQUAL. Uses the function FUnion. MAXIMIZE form [I.S. Operator] MINIMIZE form [I.S. Operator] Computes the numerically largest (smallest) instance of form and returns it as the value of the i.s. Differs from LARGEST (SMALLEST) in that the largest (smallest) value of form is returned, rather than value of the i.v. that produced the largest (smallest) value of form. UNIQUE form [I.S. Operator] If form evaluates to non-NIL exactly once during the iteration then that value is returned, else NIL. The i.v. is left set to the value that caused form to be non-NIL, for use either in a FINALLY or outside the loop in the case of (FOR OLD x IN --). For example, (FOR x IN '(1 2 3) UNIQUE (EVENP x) FINALLY (PRINT x)) will print 2 and return T (the value of (EVENP 2)). Other I. S. OPRS REPEATEACHTIME form [I.S. Operator] Causes form to be evaluated on each iteration after the main body of the loop. For example, (FOR x IN L COLLECT (F x) REPEATEACHTIME (G x)) will collect all the (F x)s, evaluating (G x) each time AFTER (F x) is evaluated). FIRSTTIME form [I.S. Operator] form is evaluated on the first iteration instead of the main body. (FOR x IN '(1 2 3) FIRSTTIME (G x) DO (F x)) will evaluate (G 1), (F 2) and (F 3). YIELD form [I.S. Operator] The value of form is returned as the value of the i.s. after the i.s. terminates normally. (Equivalent to FINALLY RETURN form). THEN form [I.S. Operator] If the value of the i.s. would otherwise have been non-NIL, then the value of form is returned, else NIL. Most useful with NEVER, ALWAYS and THEREIS. For example, (FOR x IN L NEVER (EVENP x) THEN (PRINT 'NEVER!)) will print (and return) NEVER! iff all elements of L are odd. ELSE form [I.S. Operator] Similar to THEN but evaluates and returns form iff the i.s. would otherwise have returned NIL. (LIST ((PAGE NIL (PAPERSIZE Letter FOLIOINFO (ARABIC ) STARTINGPAGE# 1) (0 0 612 792) ((FOLIO NIL (PARALOOKS (QUAD CENTERED) CHARLOOKS (SUPERSCRIPT 0 INVISIBLE OFF SELECTPOINT OFF PROTECTED OFF SIZE 10 FAMILY MODERN OVERLINE OFF STRIKEOUT OFF UNDERLINE OFF EXPANSION REGULAR SLOPE REGULAR WEIGHT MEDIUM INVERTED OFF USERINFO NIL STYLE NIL) FORMATINFO (ARABIC )) (174 36 288 36) NIL) (HEADING NIL (HEADINGTYPE RUNNINGHEAD) (84 744 528 36) NIL) (TEXT NIL NIL (84 96 456 600) NIL))) (PAGE NIL (PAPERSIZE Letter FOLIOINFO (ARABIC )) (0 0 612 792) ((FOLIO NIL (PARALOOKS (QUAD CENTERED) CHARLOOKS (SUPERSCRIPT 0 INVISIBLE OFF SELECTPOINT OFF PROTECTED OFF SIZE 10 FAMILY MODERN OVERLINE OFF STRIKEOUT OFF UNDERLINE OFF EXPANSION REGULAR SLOPE REGULAR WEIGHT MEDIUM INVERTED OFF USERINFO NIL STYLE NIL) FORMATINFO (ARABIC )) (174 36 288 36) NIL) (HEADING NIL (HEADINGTYPE RUNNINGHEAD) (84 744 528 36) NIL) (TEXT NIL NIL (84 96 456 600) NIL))) (PAGE NIL (PAPERSIZE Letter FOLIOINFO (ARABIC )) (0 0 612 792) ((FOLIO NIL (PARALOOKS (QUAD CENTERED) CHARLOOKS (SUPERSCRIPT 0 INVISIBLE OFF SELECTPOINT OFF PROTECTED OFF SIZE 10 FAMILY MODERN OVERLINE OFF STRIKEOUT OFF UNDERLINE OFF EXPANSION REGULAR SLOPE REGULAR WEIGHT MEDIUM INVERTED OFF USERINFO NIL STYLE NIL) FORMATINFO (ARABIC )) (174 36 288 36) NIL) (HEADING NIL (HEADINGTYPE RUNNINGHEAD) (84 744 528 36) NIL) (TEXT NIL NIL (84 96 456 600) NIL)))))1È È(È (È(ŠŠ8(ŠŠ8DÈÈ PAGEHEADING RUNNINGHEAD(MODERN MODERN MODERN MODERNLOGOMODERN   HRULE.GETFNMODERN  HRULE.GETFNMODERN  HRULE.GETFNMODERN   HRULE.GETFNMODERN  HRULE.GETFNMODERN " ¨  "J ~7O œK ®ZŽÛÕ ’ iNÅ*1 ùˆzº