Next: maximize - maximizing - minimize - minimizing, Previous: append - appending - nconc - nconcing, Up: Value Accumulation [Contents][Index]
count expr [into var] [type-spec] counting expr [into var] [type-spec]
varvar is specified, the loop does
not return the final count automatically. The var argument is bound as
if by the construct ‘with’.
var is used, the optional ‘type-spec’ argument specifies a data
type for var. If there is no ‘into’ variable, the optional ‘type-spec’
argument applies to the internal variable that is keeping the count. In
either case it is an error to specify a non-numeric data type. The default
type is implementation-dependent, but it must be a subtype of (or integer
float).
;;; Sum the elements of a list.
(loop for i fixnum in '(1 2 3 4 5)
sum i)
;;; Sum a function of elements of a list.
(setq series
'(1.2 4.3 5.7))
(loop for v in series
sum (* 2.0 v))