The Grinnell Scheme Web: The
integer? procedure

Does the integer? procedure distinguish whole numbers from other numbers, or from all other values, whether or not they are numbers?

From all other values. The operand of the integer? procedure can be any value whatever; integer? returns the ``true'' Boolean value just in case the operand is not only a number but an integer. (Complex numbers with non-zero imaginary parts do not count as integers, for this purpose, even if the coefficients of the real and imaginary parts are both integers.)

Can you give some examples?

Sure:

> (integer? 5)
#t
> (integer? -7)
#t
> (integer? 5.3)
#f
> (integer? 5.0)
#t
> (integer? #t)
#f
> (integer? +)
#f
That is: Five is an integer; minus seven is an integer; five and three-tenths is not an integer; five and no tenths is an integer (it's the same as five), even though the numeral we used to express it contains a decimal point; the ``true'' Boolean value is not an integer; the addition procedure is not an integer.

The integer? procedure has arity 1; giving it more operands, or none at all, is an error.


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/integer-ques.html


created July 1, 1995
last revised December 29, 1995

Copyright 1995 by John David Stone (stone@math.grin.edu)