Abstract
No computer language can function at a level beyond the trivial without some mechanism for handling different processes under different conditions. Every procedural language you can think of has an ‘IF’ statement to do this. Lisp has no statements, so it can’t have one called ‘IF’. However, if you think about the mechanism employed in a statement like:
the expression x = 3 is evaluated to TRUE or FALSE and the body of the statement is executed only if the result was TRUE. Clearly, Lisp could have functions that return these two logical values to do the same kind of job. It does, and they are called predicates. A predicate is a function that returns T or NIL. Now you know why I couldn’t abbreviate ‘tail’ to ‘t’ in Chapter 2. Lisp would have taken it as an attempt to alter the reserved atom T and complained. I have previously commented that NIL can mean FALSE. An example of a predicate which takes any Lisp object as an argument is atom. This returns T if the argument is an atom and NIL otherwise. So:
will return T, but:
will return NIL.
“All right so far,” said the King; and he went on muttering over the verses to himself: “‘We know it to be true’”.
Alice’s Adventures in Wonderland
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Preview
Unable to display preview. Download preview PDF.
Author information
Authors and Affiliations
Rights and permissions
Copyright information
© 1990 Springer-Verlag London Limited
About this chapter
Cite this chapter
Jones, R., Maynard, C., Stewart, I. (1990). Predicates. In: The Art of Lisp Programming. Springer, London. https://doi.org/10.1007/978-1-4471-1719-3_3
Download citation
DOI: https://doi.org/10.1007/978-1-4471-1719-3_3
Publisher Name: Springer, London
Print ISBN: 978-3-540-19568-9
Online ISBN: 978-1-4471-1719-3
eBook Packages: Springer Book Archive