How do I find the greatest of a group of numbers?
Call the max procedure, giving it all of the numbers as
operands:
That seems straightforward. Do the operands have to be integers?> (max 37 41) 41 > (max -83 -17 -218 -62 -718) -17 > (max 12) 12 > (max 14 14 14 -3 14 12 14 5 14) 14
No, any or all of them can be rationals or reals, if the implementation
supports such numbers. The max procedure cannot accept
complex numbers as operands, however, since they are not uniquely ordered
as ``less'' and ``greater.''
Can the max procedure receive any number of operands?
Any number except zero. It makes no sense to try to find the greatest of an empty collection of numbers.
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/max.html