Home Previous Up Next Table of Contents Index
  6.1 The LOOP Facility   6.1.2 Variable Initialization and Stepping Clauses   6.1.2.1 Iteration Control   6.1.2.1.2 The for-as-in-list subclause

6.1.2.1.2.1 Examples of for-as-in-list subclause

;; Print every item in a list.
 (loop for item in '(1 2 3) do (print item))
1
2
3
  NIL
 
;; Print every other item in a list.
 (loop for item in '(1 2 3 4 5) by #'cddr
       do (print item))
1
3
5
  NIL
 
;; Destructure a list, and sum the x values using fixnum arithmetic.
 (loop for (item . x) of-type (t . fixnum) in '((A . 1) (B . 2) (C . 3))
       unless (eq item 'B) sum x)
 4

Home Previous Up Next Table of Contents Index
© Franz Inc. 1998-2002 - File last updated 6-21-2002