Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

LISP terminology

What does the letter 't' mean in LISP?

ex:

(defun last2 (lst)
   (cond ((null lst) nil)
       ((null (cdr lst)) (car lst))
        (t (last2 (cdr lst)))))

My textbook is a coursepack so it doesn't quite explain all the meanings. Thanks.

like image 920
jsan Avatar asked Nov 30 '22 22:11

jsan


2 Answers

T is the canonical true value in Common Lisp. Here it is being used as an ELSE, ensuring that the last branch of the COND is always true. (Any value other than NIL counts as true as well.)

like image 175
Peter S. Housel Avatar answered Dec 04 '22 02:12

Peter S. Housel


See the glossary of the Common Lisp Hyperspec for t.

t n. 1. a. the boolean representing true. b. the canonical generalized boolean representing true. (Although any object other than nil is considered true as a generalized boolean, t is generally used when there is no special reason to prefer one such object over another.) ...

like image 33
Rainer Joswig Avatar answered Dec 04 '22 02:12

Rainer Joswig