101 lines
2.8 KiB
HTML
101 lines
2.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> Functions, Lambda Expressions, and Macros</TITLE>
|
|
</HEAD>
|
|
<BODY>
|
|
<meta name="description" value=" Functions, Lambda Expressions, and Macros">
|
|
<meta name="keywords" value="lp">
|
|
<meta name="resource-type" value="document">
|
|
<meta name="distribution" value="global">
|
|
<P>
|
|
<BR> <HR>
|
|
<A HREF="node65.html"><IMG ALIGN=BOTTOM ALT="next" SRC="next_motif.gif"></A>
|
|
<A HREF="lp.html"><IMG ALIGN=BOTTOM ALT="up" SRC="up_motif.gif"></A>
|
|
<A HREF="node63.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="node65.html"> Eval</A>
|
|
<B>Up:</B>
|
|
<A HREF="lp.html">Lisp Primer</A>
|
|
<B> Previous:</B>
|
|
<A HREF="node63.html"> Converting Strings to </A>
|
|
<BR> <HR> <P>
|
|
<H1> Functions, Lambda Expressions, and Macros</H1>
|
|
<P>
|
|
|
|
<font size=-1><em>[We are grateful to <a
|
|
href="mailto:remmers@jremmers.org">John H. Remmers</a> for allowing
|
|
material from his <a
|
|
href="http://www.emunix.emich.edu/~remmers/337/lisp-functional-features.html">programming
|
|
languages course</a> to be incorporated into this
|
|
section.]</em></font>
|
|
|
|
<P>
|
|
|
|
Lisp incorporates a "functional programming" paradigm. A central
|
|
feature of this paradigm is that functions are "first class" objects
|
|
that can be referenced, operated upon, and returned by operators
|
|
referred to as functionals. By contrast, in traditional procedural
|
|
languages the first class objects are normally just passive data
|
|
objects such as numbers, characters, and strings.
|
|
|
|
<P>
|
|
|
|
In a functional language, programming involves applying functionals in
|
|
various ways instead of manipulating variables by assignments, loops,
|
|
etc.
|
|
|
|
<P>
|
|
|
|
Common Lisp is not a "pure" functional language, because it contains
|
|
constructs such as SETQ, LET, and DOTIMES that mimic the assignment,
|
|
local scope, and loop features found in procedural languages. However,
|
|
Lisp does contain a number of functionals and supports a functional
|
|
style of programming.
|
|
|
|
<P>
|
|
|
|
Some of the most important and commonly used functionals are described
|
|
below, along with other elements of Lisp such as <TT>eval</TT> and
|
|
<TT>defmacro</TT> that support functional programming.
|
|
|
|
<P>
|
|
<BR> <HR>
|
|
<UL>
|
|
<LI>
|
|
<A HREF="node65.html">
|
|
Eval</A>
|
|
|
|
<LI>
|
|
<A HREF="node66.html">
|
|
Lambda Expressions</A>
|
|
|
|
<LI>
|
|
<A HREF="node67.html">
|
|
Funcall</A>
|
|
|
|
<LI>
|
|
<A HREF="node68.html">
|
|
Apply</A>
|
|
|
|
<LI>
|
|
<A HREF="node69.html">
|
|
Mapcar</A>
|
|
|
|
<LI>
|
|
<A HREF="node70.html">
|
|
Backquote and Commas</A>
|
|
|
|
<LI>
|
|
<A HREF="node71.html">
|
|
Defmacro</A>
|
|
|
|
</UL>
|
|
<BR> <HR>
|
|
<P>
|
|
<ADDRESS>
|
|
<I>© Colin Allen, John H. Remmers, & Maneesh Dhagat <BR>
|
|
March 2007 </I>
|
|
</ADDRESS>
|
|
</BODY>
|