How do I multiply numbers in Scheme?
Call the * procedure, and give it all of the numbers you want
to multiply as operands. Here are some examples:
The> (* 11 13) 143 > (* -9 -111111111111) 999999999999 > (* 1 2 3 4 5) 120
* procedure accepts numbers of any supported type as
operands:
Does> (* 3/4 -1/3 1/12) -1/48 > (* 7.2+6.1i -4.3i) 26.23-30.96i
* accept any number of operands, like +?
What does it return if you give it one operand or none?
Yes, you can give * any number of operands. The ``product''
of one number is that number itself, and the ``product'' of no numbers is
the multiplicative identity, 1:
Again, this makes sense analogically:> (* 53) 53 > (*) 1
(* 5 5 5) is 125,
(* 5 5) is 25, (* 5) is 5, so naturally
(*) is 1.
Next topic
Previous topic
Table of contents
This document is available on the World Wide Web as
http://www.math.grin.edu/~stone/scheme-web/times.html