The floor
Hyperspec article on dotimes
has this example:
(defun palindromep (string &optional
(start 0)
(end (length string)))
(dotimes (k (floor (- end start) 2) t)
(unless (char-equal (char string (+ start k))
(char string (- end k 1)))
(return nil))))
If floor
returns two values, e.g. (floor 5 2)
-> 2
and 1
, how does dotimes
know to just use the first value and disregard the second for its count-form?
From 7.10.1,
Normally multiple values are not used. Special forms are required both to produce multiple values and to receive them. If the caller of a function does not request multiple values, but the called function produces multiple values, then the first value is given to the caller and all others are discarded; if the called function produces zero values, then the caller gets
nil
as a value.
Unless you specifically do something to deal with the multiple values (such as by multiple-value-call
or one of the various macros equipped to handle them), all except the first value will be ignored.