Lisp, Function NULL, Step 3.

30/07/19, modified 30/07/19

I wanted to check for an empty string, and so came by the Function NULL. Finally, a well specified function. The description;

Returns t if object is the empty list; otherwise, returns nil.

Luckily, in Common LISP the "empty list" and "nil" are one and the same, so this sentence can be written as is1.

And the examples;

 (null '()) =>  T
 (null nil) =>  T
 (null t) =>  NIL
 (null 1) =>  NIL

Also fine, the four cases you would expect here.

But then, the last line of the notes;

 (null object) ==  (typep object 'null) ==  (eq object '())

Now, how does help? the author could not be bothered to add some text here? Is "==" somehow part of the syntax?

  1. Try this; Returns t if object is nil; otherwise, returns nil.

    Or this; Returns t if object is the empty list; otherwise, returns the empty list.

    I seem to also getting infected with this LISP virus to look for the edge cases []

3 Responses to “Lisp, Function NULL, Step 3.”

  1. You seem to be making your way towards Backus-Naur forms, rewriting rules & context free grammars... say, ever read Chomsky ?

  2. ave1 says:

    No never read, (but I did see his name come by in the logs) where should I start ? at "Syntactic Structures"?

  3. Chomsky is a linguist ; his lifetime preoccupation is with AST-ing natural languages. His work is coincidentally related to mathematicians' work on synthetic languages, for which reason there's no should. You may find it entertaining to read, in your spare time as an old man. Maybe worth looking from Knuth's pov : http://www-cs-faculty.stanford.edu/~knuth/cl.html

Leave a Reply to Mircea Popescu