65 lines
1.8 KiB
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 <func> <lis1> . . . <lisN> )</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>> (mapcar '+ '(1 2 3))
|
|
(1 2 3)
|
|
|
|
> (mapcar '+ '(1 2 3) '(4 5 6))
|
|
(5 7 9)
|
|
|
|
> (mapcar '+ '(1 2 3) '(4 5 6) '(7 8 9))
|
|
(12 15 18)
|
|
|
|
> (mapcar '+ '(1 2) '(3 4 5))
|
|
(4 6)
|
|
|
|
> (mapcar '< '(1 2 3) '(4 5 0))
|
|
(T T NIL)
|
|
|
|
> (mapcar '< '(1 2 3) '(4 5))
|
|
(T T)
|
|
</PRE>
|
|
</BLOCKQUOTE>
|
|
<P>
|
|
<BR> <HR>
|
|
<P>
|
|
<ADDRESS>
|
|
<I>© Colin Allen & Maneesh Dhagat <BR>
|
|
March 2007 </I>
|
|
</ADDRESS>
|
|
</BODY>
|