emacs.d/clones/colinallen.dnsalias.org/lp/node101.html

65 lines
1.8 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> mapcar (FUNCTION)</TITLE>
</HEAD>
<BODY>
<meta name="description" value=" mapcar (FUNCTION)">
<meta name="keywords" value="lp">
<meta name="resource-type" value="document">
<meta name="distribution" value="global">
<P>
<BR> <HR>
<A HREF="node102.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="node100.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="node102.html"> maxmin (FUNCTIONS)</A>
<B>Up:</B>
<A HREF="node72.html"> Appendix: Selected Lisp </A>
<B> Previous:</B>
<A HREF="node100.html"> listp (PREDICATE)</A>
<BR> <HR> <P>
<H1> mapcar (FUNCTION)</H1>
<P>
<b> Format:</b>
<tt> (mapcar &lt;func&gt; &lt;lis1&gt; . . . &lt;lisN&gt; )</tt>
<P>
<b> Required arguments:</b>
2
<P>
First argument names a function (usually quoted). Subsequent arguments must evaluate to lists.
<P>
Mapcar applies the named function successively to the first, second, third, etc. elements of the subsequent arguments and returns a list of the results, up to the length of the shortest list provided.
<P>
<b> Examples:</b>
<P>
<BLOCKQUOTE>
<PRE>&gt; (mapcar '+ '(1 2 3))
(1 2 3)
&gt; (mapcar '+ '(1 2 3) '(4 5 6))
(5 7 9)
&gt; (mapcar '+ '(1 2 3) '(4 5 6) '(7 8 9))
(12 15 18)
&gt; (mapcar '+ '(1 2) '(3 4 5))
(4 6)
&gt; (mapcar '&lt; '(1 2 3) '(4 5 0))
(T T NIL)
&gt; (mapcar '&lt; '(1 2 3) '(4 5))
(T T)
</PRE>
</BLOCKQUOTE>
<P>
<BR> <HR>
<P>
<ADDRESS>
<I>&#169; Colin Allen &amp; Maneesh Dhagat <BR>
March 2007 </I>
</ADDRESS>
</BODY>