What exactly is the parity of a number?
The parity of an integer is whether it is even or odd -- that is, whether or not it is evenly divisible by 2. Only integers have parity.
How do you determine the parity of an integer in Scheme?
You have your choice of two procedures, odd? and even?. They're exactly
complementary. If you're watching out for an integer that is not evenly
divisible by 2 for some reason, call the odd? procedure:
The arity of the> (odd? 7) #t > (odd? -8) #f > (odd? 0) #f > (odd? 5.9) ERROR: odd?: Wrong type in arg1 5.9
odd? procedure is 1, and the operand must be
an integer.
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/odd-ques.html