61 lines
1.5 KiB
HTML
61 lines
1.5 KiB
HTML
|
<!DOCTYPE HTML PUBLIC "-//W3O//DTD W3 HTML 2.0//EN">
|
||
|
<!Originally converted to HTML using LaTeX2HTML 95 (Thu Jan 19 1995) by Nikos Drakos (nikos@cbl.leeds.ac.uk), CBLU, University of Leeds >
|
||
|
<HEAD>
|
||
|
<TITLE> Checking for NIL</TITLE>
|
||
|
</HEAD>
|
||
|
<BODY>
|
||
|
<meta name="description" value=" Checking for NIL">
|
||
|
<meta name="keywords" value="lp">
|
||
|
<meta name="resource-type" value="document">
|
||
|
<meta name="distribution" value="global">
|
||
|
<P>
|
||
|
<BR> <HR>
|
||
|
<A HREF="node27.html"><IMG ALIGN=BOTTOM ALT="next" SRC="next_motif.gif"></A>
|
||
|
<A HREF="node24.html"><IMG ALIGN=BOTTOM ALT="up" SRC="up_motif.gif"></A>
|
||
|
<A HREF="node25.html"><IMG ALIGN=BOTTOM ALT="previous" SRC="previous_motif.gif"></A> <BR>
|
||
|
<A HREF="lp.html"><B>Contents</B></A>
|
||
|
<B> Next:</B>
|
||
|
<A HREF="node27.html"> Logical Operators: And </A>
|
||
|
<B>Up:</B>
|
||
|
<A HREF="node24.html"> More Predicates and </A>
|
||
|
<B> Previous:</B>
|
||
|
<A HREF="node25.html"> Equality Predicates</A>
|
||
|
<BR> <HR> <P>
|
||
|
<H2> Checking for NIL</H2>
|
||
|
<P>
|
||
|
The predicates null and not act identically. Good programming style dictates that you use null when the semantics of the program suggest interest in whether a list is empty, otherwise use not:
|
||
|
<BLOCKQUOTE>
|
||
|
<PRE>> (null nil)
|
||
|
T
|
||
|
|
||
|
> (not nil)
|
||
|
T
|
||
|
|
||
|
> (null ())
|
||
|
T
|
||
|
|
||
|
> (not ()) ;;preferable to use null
|
||
|
T
|
||
|
|
||
|
> (null '(a s))
|
||
|
NIL
|
||
|
|
||
|
> (not '(a s)) ;;preferable to use null
|
||
|
NIL
|
||
|
|
||
|
> (not (= 1 (* 1 1)))
|
||
|
NIL
|
||
|
|
||
|
> (null (= 1 (* 1 1))) ;;preferable to use not
|
||
|
NIL
|
||
|
</PRE>
|
||
|
</BLOCKQUOTE>
|
||
|
<P>
|
||
|
<BR> <HR>
|
||
|
<P>
|
||
|
<ADDRESS>
|
||
|
<I>© Colin Allen & Maneesh Dhagat <BR>
|
||
|
March 2007 </I>
|
||
|
</ADDRESS>
|
||
|
</BODY>
|