68 lines
1.9 KiB
HTML
68 lines
1.9 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> butlast (FUNCTION)</TITLE>
|
||
|
</HEAD>
|
||
|
<BODY>
|
||
|
<meta name="description" value=" butlast (FUNCTION)">
|
||
|
<meta name="keywords" value="lp">
|
||
|
<meta name="resource-type" value="document">
|
||
|
<meta name="distribution" value="global">
|
||
|
<P>
|
||
|
<BR> <HR>
|
||
|
<A HREF="node84.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="node82.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="node84.html"> car (FUNCTION)</A>
|
||
|
<B>Up:</B>
|
||
|
<A HREF="node72.html"> Appendix: Selected Lisp </A>
|
||
|
<B> Previous:</B>
|
||
|
<A HREF="node82.html"> atom (PREDICATE)</A>
|
||
|
<BR> <HR> <P>
|
||
|
<H1> butlast (FUNCTION)</H1>
|
||
|
<P>
|
||
|
<b> Format:</b>
|
||
|
<tt> (butlast <list> )</tt>
|
||
|
<tt> (butlast <list> <int> )</tt>
|
||
|
<P>
|
||
|
<b> Required arguments:</b>
|
||
|
1
|
||
|
<P>
|
||
|
First argument must evaluate to a list
|
||
|
<P>
|
||
|
<b> Optional arguments:</b>
|
||
|
1
|
||
|
<P>
|
||
|
<tt> <int> </tt> must evaluate to an integer
|
||
|
<P>
|
||
|
If butlast is used with a single argument then it is equivalent to <tt> (reverse (rest (reverse <list> )))</tt>. I.e. it will return the list argument with the last element removed.
|
||
|
<P>
|
||
|
If butlast is given an integer second argument, it is equivalent to <tt> (reverse (nthcdr <num> (reverse <list> )))</tt>. I.e. it will remove the number of elements specified from the end of the list.
|
||
|
<P>
|
||
|
<b> Examples:</b>
|
||
|
<P>
|
||
|
<BLOCKQUOTE>
|
||
|
<PRE>> (butlast '(a s d f))
|
||
|
(A S D)
|
||
|
|
||
|
> (butlast '(a s d f) 2)
|
||
|
(A S)
|
||
|
|
||
|
> (butlast '(a s d f) 0)
|
||
|
(A S D F)
|
||
|
|
||
|
> (reverse (nthcdr 2 (reverse '(a s d f))))
|
||
|
(A S)
|
||
|
</PRE>
|
||
|
</BLOCKQUOTE>
|
||
|
<P>
|
||
|
<BR> <HR>
|
||
|
<P>
|
||
|
<ADDRESS>
|
||
|
<I>© Colin Allen & Maneesh Dhagat <BR>
|
||
|
March 2007 </I>
|
||
|
</ADDRESS>
|
||
|
</BODY>
|