emacs.d/clones/lisp/colinallen.dnsalias.org/lp/node105.html

61 lines
1.8 KiB
HTML
Raw Normal View History

2022-08-02 12:34:59 +02:00
<!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> nth (FUNCTION)</TITLE>
</HEAD>
<BODY>
<meta name="description" value=" nth (FUNCTION)">
<meta name="keywords" value="lp">
<meta name="resource-type" value="document">
<meta name="distribution" value="global">
<P>
<BR> <HR>
<A HREF="node106.html"><IMG ALIGN=BOTTOM ALT="next" SRC="next_motif.gif"></A>
<A HREF="node72.html"><IMG ALIGN=BOTTOM ALT="up" SRC="up_motif.gif"></A>
<A HREF="node104.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="node106.html"> nthcdr (FUNCTION)</A>
<B>Up:</B>
<A HREF="node72.html"> Appendix: Selected Lisp </A>
<B> Previous:</B>
<A HREF="node104.html"> not (PREDICATE)</A>
<BR> <HR> <P>
<H1> nth (FUNCTION)</H1>
<P>
<b> Format:</b>
<tt> (nth &lt;index&gt; &lt;list&gt; )</tt>
<P>
<b> Required arguments:</b>
2
<P>
<tt> &lt;index&gt; </tt>: any expression which returns a positive integer (fixnum).
<tt> &lt;list&gt; </tt>: any expression which returns a list.
<P>
The function nth returns the indexed element of <tt> &lt;list&gt; </tt>. <tt> &lt;index&gt; </tt> must
be a non-negative integer. 0 indicates the first element of <tt> &lt;list&gt; </tt>,
1 the second, etc. An index past the end of the list will cause nth to
return nil.
<P>
<b> Examples:</b>
<P>
<BLOCKQUOTE>
<PRE>&gt; (nth 0 '(picard riker work crusher))
PICARD
&gt; (nth 2 '((captain picard)
(commander riker)
(lieutenant worf)
(ensign crusher)))
(LIEUTENANT WORF)
</PRE>
</BLOCKQUOTE>
<P>
<BR> <HR>
<P>
<ADDRESS>
<I>&#169; Colin Allen &amp; Maneesh Dhagat <BR>
March 2007 </I>
</ADDRESS>
</BODY>