*
* Function
Syntax:
* &rest numbers → product
Arguments and Values:
number—a number .
product—a number .
Description:
Returns the product of numbers, performing any necessary type conversions in the process. If no numbers are supplied, 1 is returned.
Examples:
(\*) → 1
(\* 3 5) → 15
(\* 1.0 #c(22 33) 55/98) → #C(12.346938775510203 18.520408163265305)
Exceptional Situations:
Might signal type-error if some argument is not a number . Might signal arithmetic-error.
See Also:
Section 12.1.1 (Numeric Operations), Section 12.1.3 (Rational Computations), Section 12.1.4 (Floating-point Computations), Section 12.1.5 (Complex Computations)
Expanded Reference: *
Basic multiplication
* returns the product of its arguments. With no arguments, it returns the multiplicative identity 1.
(*)
=> 1
(* 6)
=> 6
(* 3 5)
=> 15
(* 2 3 4 5)
=> 120
Rational multiplication
With rational arguments, the result is an exact rational.
(* 1/2 1/3)
=> 1/6
(* 3/4 4/3)
=> 1
(* 2 3/5)
=> 6/5
Floating-point contagion
If any argument is a float, the result is a float.
(* 2 3.0)
=> 6.0
(* 0.5 10)
=> 5.0
(* 1.0d0 3)
=> 3.0d0
Complex multiplication
* works with complex numbers following standard complex multiplication rules.
(* #c(0 1) #c(0 1))
=> -1
(* #c(1 1) #c(1 -1))
=> 2
(* #c(2 3) 2)
=> #C(4 6)
Computing factorials
* is useful with reduce or apply for computing products over sequences.
(reduce #'* '(1 2 3 4 5))
=> 120
(apply #'* (loop for i from 1 to 10 collect i))
=> 3628800