Skip to main content

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:

$$IF\;x = 3\;THEN\; \ldots$$

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:

$$\begin{array}{*{20}{c}} {\left( {setq\;x\;{}^\backprime a} \right)} \\ {\left( {atom\;x} \right)} \\ \end{array}$$

will return T, but:

$$\left( {atom\;fig\_6} \right)$$

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

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 39.99
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 54.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

Author information

Authors and Affiliations

Authors

Rights and permissions

Reprints 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

Publish with us

Policies and ethics