Commit 16d89769 authored by Dave Cooper's avatar Dave Cooper
Browse files

added depends-on for gdl-robot.asd, so it will make it into Quicklisp's...

added depends-on for gdl-robot.asd, so it will make it into Quicklisp's systems.txt file, which is necessary for genworks-gdl.asd since :genworks-gdl depends on robot.asd.
parent 755db3ce
......@@ -37,7 +37,9 @@
(release-name-mapping '(("acl-8.2m-linux-x86" . "gdl1581-linux")
("acl-8.2m-win-x86" . "gdl1581-windows")
("acl-9.0m-linux-x86" . "gdl1582-linux")
("acl-9.0m-win-x86" . "gdl1582-windows")))
("acl-9.0m-win-x86" . "gdl1582-windows")
("acl-9.0ms-win-x64" . "gdl1582-win64smp")
))
(os-name-mapping '(("win" . "windows")
("linux" . "linux")
......
(:gdl-gwl-graphics)
\ No newline at end of file
......@@ -9,8 +9,8 @@
:serial
t
:version
"2012111900"
"2012112900"
:depends-on
nil
(:gdl-gwl-graphics)
:components
((:file "source/package") (:file "source/assembly")))
\ No newline at end of file
This is makeindex, version 2.15 [TeX Live 2012] (kpathsea + Thai support).
This is makeindex, version 2.15 [TeX Live 2011] (kpathsea + Thai support).
Scanning input file tutorial.idx....done (37 entries accepted, 0 rejected).
Sorting entries....done (208 comparisons).
Generating output file tutorial.ind....done (81 lines written, 0 warnings).
......
This is pdfTeX, Version 3.1415926-2.4-1.40.13 (TeX Live 2012/MacPorts 2012_1) (format=pdflatex 2012.8.4) 21 NOV 2012 12:14
This is pdfTeX, Version 3.1415926-2.3-1.40.12 (TeX Live 2011/MacPorts 2011_5) (format=pdflatex 2012.4.16) 26 NOV 2012 19:04
entering extended mode
restricted \write18 enabled.
%&-line parsing enabled.
**tutorial.tex
(./tutorial.tex
LaTeX2e <2011/06/27>
Babel <v3.8m> and hyphenation patterns for english, dumylang, nohyphenation, cz
ech, slovak, dutch, ukenglish, usenglishmax, basque, french, german-x-2012-05-3
0, ngerman-x-2012-05-30, german, ngerman, swissgerman, italian, polish, portugu
ese, spanish, catalan, galician, ukenglish, loaded.
LaTeX2e <2009/09/24>
Babel <v3.8l> and hyphenation patterns for english, dumylang, nohyphenation, cz
ech, slovak, dutch, ukenglish, usenglishmax, basque, french, german-x-2009-06-1
9, ngerman-x-2009-06-19, german, ngerman, swissgerman, italian, polish, portugu
ese, spanish, catalan, galician, loaded.
(/opt/local/share/texmf-texlive-dist/tex/latex/base/book.cls
Document Class: book 2007/10/19 v1.4h Standard LaTeX document class
(/opt/local/share/texmf-texlive-dist/tex/latex/base/bk11.clo
......@@ -63,10 +63,10 @@ Package color Info: Driver file: pdftex.def on input line 130.
File: pdftex.def 2011/05/27 v0.06d Graphics/color for pdfTeX
(/opt/local/share/texmf-texlive-dist/tex/generic/oberdiek/infwarerr.sty
Package: infwarerr 2010/04/08 v1.3 Providing info/warning/error messages (HO)
Package: infwarerr 2010/04/08 v1.3 Providing info/warning/message (HO)
)
(/opt/local/share/texmf-texlive-dist/tex/generic/oberdiek/ltxcmds.sty
Package: ltxcmds 2011/11/09 v1.22 LaTeX kernel commands for general use (HO)
Package: ltxcmds 2011/04/18 v1.20 LaTeX kernel commands for general use (HO)
)
\Gread@gobject=\count88
)
......@@ -126,130 +126,113 @@ Package textcomp Info: Setting pxtt sub-encoding to TS1/0 on input line 307.
Package textcomp Info: Setting txr sub-encoding to TS1/0 on input line 308.
Package textcomp Info: Setting txss sub-encoding to TS1/0 on input line 309.
Package textcomp Info: Setting txtt sub-encoding to TS1/0 on input line 310.
Package textcomp Info: Setting lmr sub-encoding to TS1/0 on input line 311.
Package textcomp Info: Setting lmdh sub-encoding to TS1/0 on input line 312.
Package textcomp Info: Setting lmss sub-encoding to TS1/0 on input line 313.
Package textcomp Info: Setting lmssq sub-encoding to TS1/0 on input line 314.
Package textcomp Info: Setting lmvtt sub-encoding to TS1/0 on input line 315.
Package textcomp Info: Setting qhv sub-encoding to TS1/0 on input line 316.
Package textcomp Info: Setting qag sub-encoding to TS1/0 on input line 317.
Package textcomp Info: Setting qbk sub-encoding to TS1/0 on input line 318.
Package textcomp Info: Setting qcr sub-encoding to TS1/0 on input line 319.
Package textcomp Info: Setting qcs sub-encoding to TS1/0 on input line 320.
Package textcomp Info: Setting qpl sub-encoding to TS1/0 on input line 321.
Package textcomp Info: Setting qtm sub-encoding to TS1/0 on input line 322.
Package textcomp Info: Setting qzc sub-encoding to TS1/0 on input line 323.
Package textcomp Info: Setting qhvc sub-encoding to TS1/0 on input line 324.
Package textcomp Info: Setting futs sub-encoding to TS1/4 on input line 325.
Package textcomp Info: Setting futx sub-encoding to TS1/4 on input line 326.
Package textcomp Info: Setting futj sub-encoding to TS1/4 on input line 327.
Package textcomp Info: Setting hlh sub-encoding to TS1/3 on input line 328.
Package textcomp Info: Setting hls sub-encoding to TS1/3 on input line 329.
Package textcomp Info: Setting hlst sub-encoding to TS1/3 on input line 330.
Package textcomp Info: Setting hlct sub-encoding to TS1/5 on input line 331.
Package textcomp Info: Setting hlx sub-encoding to TS1/5 on input line 332.
Package textcomp Info: Setting hlce sub-encoding to TS1/5 on input line 333.
Package textcomp Info: Setting hlcn sub-encoding to TS1/5 on input line 334.
Package textcomp Info: Setting hlcw sub-encoding to TS1/5 on input line 335.
Package textcomp Info: Setting hlcf sub-encoding to TS1/5 on input line 336.
Package textcomp Info: Setting pplx sub-encoding to TS1/3 on input line 337.
Package textcomp Info: Setting pplj sub-encoding to TS1/3 on input line 338.
Package textcomp Info: Setting ptmx sub-encoding to TS1/4 on input line 339.
Package textcomp Info: Setting ptmj sub-encoding to TS1/4 on input line 340.
Package textcomp Info: Setting futs sub-encoding to TS1/4 on input line 311.
Package textcomp Info: Setting futx sub-encoding to TS1/4 on input line 312.
Package textcomp Info: Setting futj sub-encoding to TS1/4 on input line 313.
Package textcomp Info: Setting hlh sub-encoding to TS1/3 on input line 314.
Package textcomp Info: Setting hls sub-encoding to TS1/3 on input line 315.
Package textcomp Info: Setting hlst sub-encoding to TS1/3 on input line 316.
Package textcomp Info: Setting hlct sub-encoding to TS1/5 on input line 317.
Package textcomp Info: Setting hlx sub-encoding to TS1/5 on input line 318.
Package textcomp Info: Setting hlce sub-encoding to TS1/5 on input line 319.
Package textcomp Info: Setting hlcn sub-encoding to TS1/5 on input line 320.
Package textcomp Info: Setting hlcw sub-encoding to TS1/5 on input line 321.
Package textcomp Info: Setting hlcf sub-encoding to TS1/5 on input line 322.
Package textcomp Info: Setting pplx sub-encoding to TS1/3 on input line 323.
Package textcomp Info: Setting pplj sub-encoding to TS1/3 on input line 324.
Package textcomp Info: Setting ptmx sub-encoding to TS1/4 on input line 325.
Package textcomp Info: Setting ptmj sub-encoding to TS1/4 on input line 326.
)
(/opt/local/share/texmf-texlive-dist/tex/latex/hyperref/hyperref.sty
Package: hyperref 2012/05/13 v6.82q Hypertext links for LaTeX
Package: hyperref 2011/04/17 v6.82g Hypertext links for LaTeX
(/opt/local/share/texmf-texlive-dist/tex/generic/oberdiek/hobsub-hyperref.sty
Package: hobsub-hyperref 2012/05/28 v1.13 Bundle oberdiek, subset hyperref (HO)
Package: hobsub-hyperref 2011/04/23 v1.4 Bundle oberdiek, subset hyperref (HO)
(/opt/local/share/texmf-texlive-dist/tex/generic/oberdiek/hobsub-generic.sty
Package: hobsub-generic 2012/05/28 v1.13 Bundle oberdiek, subset generic (HO)
Package: hobsub 2012/05/28 v1.13 Construct package bundles (HO)
Package: hobsub-generic 2011/04/23 v1.4 Bundle oberdiek, subset generic (HO)
Package: hobsub 2011/04/23 v1.4 Subsetting bundle oberdiek (HO)
Package hobsub Info: Skipping package `infwarerr' (already loaded).
Package hobsub Info: Skipping package `ltxcmds' (already loaded).
Package: ifluatex 2010/03/01 v1.3 Provides the ifluatex switch (HO)
Package ifluatex Info: LuaTeX not detected.
Package: ifvtex 2010/03/01 v1.5 Detect VTeX and its facilities (HO)
Package: ifvtex 2010/03/01 v1.5 Switches for detecting VTeX and its modes (HO)
Package ifvtex Info: VTeX not detected.
Package: intcalc 2007/09/27 v1.1 Expandable calculations with integers (HO)
Package: intcalc 2007/09/27 v1.1 Expandable integer calculations (HO)
Package: ifpdf 2011/01/30 v2.3 Provides the ifpdf switch (HO)
Package ifpdf Info: pdfTeX in PDF mode is detected.
Package: etexcmds 2011/02/16 v1.5 Avoid name clashes with e-TeX commands (HO)
Package: etexcmds 2011/02/16 v1.5 Prefix for e-TeX command names (HO)
Package etexcmds Info: Could not find \expanded.
(etexcmds) That can mean that you are not using pdfTeX 1.50 or
(etexcmds) that some package has redefined \expanded.
(etexcmds) In the latter case, load this package earlier.
Package: kvsetkeys 2012/04/25 v1.16 Key value parser (HO)
Package: kvdefinekeys 2011/04/07 v1.3 Define keys (HO)
Package: pdftexcmds 2011/11/29 v0.20 Utility functions of pdfTeX for LuaTeX (HO
)
Package: kvsetkeys 2011/04/07 v1.13 Key value parser (HO)
Package: kvdefinekeys 2011/04/07 v1.3 Defining keys (HO)
Package: pdftexcmds 2011/04/22 v0.16 Utilities of pdfTeX for LuaTeX (HO)
Package pdftexcmds Info: LuaTeX not detected.
Package pdftexcmds Info: \pdf@primitive is available.
Package pdftexcmds Info: \pdf@ifprimitive is available.
Package pdftexcmds Info: \pdfdraftmode found.
Package: pdfescape 2011/11/25 v1.13 Implements pdfTeX's escape features (HO)
Package: bigintcalc 2012/04/08 v1.3 Expandable calculations on big integers (HO
)
Package: bitset 2011/01/30 v1.1 Handle bit-vector datatype (HO)
Package: uniquecounter 2011/01/30 v1.2 Provide unlimited unique counter (HO)
Package: pdfescape 2011/04/04 v1.12 Provides string conversions (HO)
Package: bigintcalc 2011/01/30 v1.2 Expandable big integer calculations (HO)
Package: bitset 2011/01/30 v1.1 Data type bit set (HO)
Package: uniquecounter 2011/01/30 v1.2 Provides unlimited unique counter (HO)
)
Package hobsub Info: Skipping package `hobsub' (already loaded).
Package: letltxmacro 2010/09/02 v1.4 Let assignment for LaTeX macros (HO)
Package: hopatch 2012/05/28 v1.2 Wrapper for package hooks (HO)
Package: hopatch 2011/01/30 v1.0 Wrapper for package hooks (HO)
Package: xcolor-patch 2011/01/30 xcolor patch
Package: atveryend 2011/06/30 v1.8 Hooks at the very end of document (HO)
Package atveryend Info: \enddocument detected (standard20110627).
Package: atbegshi 2011/10/05 v1.16 At begin shipout hook (HO)
Package: refcount 2011/10/16 v3.4 Data extraction from label references (HO)
Package: hycolor 2011/01/30 v1.7 Color options for hyperref/bookmark (HO)
Package: atveryend 2011/04/23 v1.7 Hooks at very end of document (HO)
Package atveryend Info: \enddocument detected (standard).
Package: atbegshi 2011/01/30 v1.15 At begin shipout hook (HO)
Package: refcount 2010/12/01 v3.2 Data extraction from references (HO)
Package: hycolor 2011/01/30 v1.7 Color options of hyperref/bookmark (HO)
)
(/opt/local/share/texmf-texlive-dist/tex/generic/ifxetex/ifxetex.sty
Package: ifxetex 2010/09/12 v0.6 Provides ifxetex conditional
)
(/opt/local/share/texmf-texlive-dist/tex/latex/oberdiek/kvoptions.sty
Package: kvoptions 2011/06/30 v3.11 Key value format for package options (HO)
Package: kvoptions 2010/12/23 v3.10 Keyval support for LaTeX options (HO)
)
\@linkdim=\dimen105
\Hy@linkcounter=\count89
\Hy@pagecounter=\count90
(/opt/local/share/texmf-texlive-dist/tex/latex/hyperref/pd1enc.def
File: pd1enc.def 2012/05/13 v6.82q Hyperref: PDFDocEncoding definition (HO)
File: pd1enc.def 2011/04/17 v6.82g Hyperref: PDFDocEncoding definition (HO)
)
\Hy@SavedSpaceFactor=\count91
(/opt/local/share/texmf-texlive-dist/tex/latex/latexconfig/hyperref.cfg
File: hyperref.cfg 2002/06/06 v1.2 hyperref configuration of TeXLive
)
Package hyperref Info: Option `colorlinks' set `true' on input line 3941.
Package hyperref Info: Hyper figures OFF on input line 4062.
Package hyperref Info: Link nesting OFF on input line 4067.
Package hyperref Info: Hyper index ON on input line 4070.
Package hyperref Info: Plain pages OFF on input line 4077.
Package hyperref Info: Backreferencing OFF on input line 4082.
Package hyperref Info: Option `colorlinks' set `true' on input line 3905.
Package hyperref Info: Hyper figures OFF on input line 4026.
Package hyperref Info: Link nesting OFF on input line 4031.
Package hyperref Info: Hyper index ON on input line 4034.
Package hyperref Info: Plain pages OFF on input line 4041.
Package hyperref Info: Backreferencing OFF on input line 4046.
Package hyperref Info: Implicit mode ON; LaTeX internals redefined.
Package hyperref Info: Bookmarks ON on input line 4300.
Package hyperref Info: Bookmarks ON on input line 4264.
\c@Hy@tempcnt=\count92
(/opt/local/share/texmf-texlive-dist/tex/latex/url/url.sty
\Urlmuskip=\muskip10
Package: url 2006/04/12 ver 3.3 Verb mode for urls, etc.
)
LaTeX Info: Redefining \url on input line 4653.
LaTeX Info: Redefining \url on input line 4617.
\Fld@menulength=\count93
\Field@Width=\dimen106
\Fld@charsize=\dimen107
Package hyperref Info: Hyper figures OFF on input line 5773.
Package hyperref Info: Link nesting OFF on input line 5778.
Package hyperref Info: Hyper index ON on input line 5781.
Package hyperref Info: backreferencing OFF on input line 5788.
Package hyperref Info: Link coloring ON on input line 5791.
Package hyperref Info: Link coloring with OCG OFF on input line 5798.
Package hyperref Info: PDF/A mode OFF on input line 5803.
LaTeX Info: Redefining \ref on input line 5843.
LaTeX Info: Redefining \pageref on input line 5847.
Package hyperref Info: Hyper figures OFF on input line 5701.
Package hyperref Info: Link nesting OFF on input line 5706.
Package hyperref Info: Hyper index ON on input line 5709.
Package hyperref Info: backreferencing OFF on input line 5716.
Package hyperref Info: Link coloring ON on input line 5719.
Package hyperref Info: Link coloring with OCG OFF on input line 5726.
Package hyperref Info: PDF/A mode OFF on input line 5731.
LaTeX Info: Redefining \ref on input line 5771.
LaTeX Info: Redefining \pageref on input line 5775.
\Hy@abspage=\count94
\c@Item=\count95
\c@Hfootnote=\count96
......@@ -258,7 +241,7 @@ LaTeX Info: Redefining \pageref on input line 5847.
Package hyperref Message: Driver (autodetected): hpdftex.
(/opt/local/share/texmf-texlive-dist/tex/latex/hyperref/hpdftex.def
File: hpdftex.def 2012/05/13 v6.82q Hyperref driver for pdfTeX
File: hpdftex.def 2011/04/17 v6.82g Hyperref driver for pdfTeX
\Fld@listcount=\count97
\c@bookmark@seq@number=\count98
......@@ -302,7 +285,7 @@ LaTeX Font Info: ... okay on input line 35.
Package: epstopdf-base 2010/02/09 v2.5 Base part for package epstopdf
(/opt/local/share/texmf-texlive-dist/tex/latex/oberdiek/grfext.sty
Package: grfext 2010/08/19 v1.1 Manage graphics extensions (HO)
Package: grfext 2010/08/19 v1.1 Managing graphics extensions (HO)
)
Package epstopdf-base Info: Redefining graphics rule for `.eps' on input line 4
34.
......@@ -598,12 +581,12 @@ LaTeX Warning: There were undefined references.
Package atveryend Info: Empty hook `AtVeryVeryEnd' on input line 1753.
)
Here is how much of TeX's memory you used:
6094 strings out of 494751
91646 string characters out of 3171015
172722 words of memory out of 3000000
9069 multiletter control sequences out of 15000+200000
6047 strings out of 494770
91107 string characters out of 3171573
170817 words of memory out of 3000000
9016 multiletter control sequences out of 15000+200000
12647 words of font info for 44 fonts, out of 3000000 for 9000
142 hyphenation exceptions out of 8191
134 hyphenation exceptions out of 8191
29i,8n,28p,455b,526s stack positions out of 5000i,500n,10000p,200000b,50000s
{/opt/local/share/texmf-texlive-dist/fonts/enc/dvips/cm-super/cm-super-ts1.en
c}</opt/local/share/texmf-texlive-dist/fonts/type1/public/amsfonts/cm/cmbx10.pf
......@@ -622,7 +605,7 @@ ocal/share/texmf-texlive-dist/fonts/type1/public/amsfonts/cm/cmtt10.pfb></opt/l
ocal/share/texmf-texlive-dist/fonts/type1/public/amsfonts/cm/cmtt9.pfb></opt/lo
cal/share/texmf-texlive-dist/fonts/type1/public/cm-super/sfrm0900.pfb></opt/loc
al/share/texmf-texlive-dist/fonts/type1/public/cm-super/sfrm1095.pfb>
Output written on tutorial.pdf (41 pages, 457341 bytes).
Output written on tutorial.pdf (41 pages, 457673 bytes).
PDF statistics:
725 PDF objects out of 1000 (max. 8388607)
653 compressed objects within 7 object streams
......
......@@ -282,3 +282,538 @@ call "
" evaluates to the number 4.")))))
#|
3.2 The List as a Data Structure
In this section we will present some of the fundamental native CL operators for manipulating
lists as data structures. These include operators for doing things such as:28 CHAPTER 3. THE CL LANGUAGE
1. finding the length of a list
2. accessing particular members of a list
3. appending multiple lists together to make a new list
4. extracting elements from a list to make a new list
3.2.1 Accessing the Elements of a List
Common Lisp defines the accessor functions first through tenth as a means of accessing
the first ten elements in a list:
CL-USER(5): (first ’(a b c))
A
CL-USER(6): (second ’(a b c))
B
CL-USER(7): (third ’(a b c))
C
For accessing elements in an arbitrary position in the list, you can use the function nth,
which takes an integer and a list as its two arguments:
CL-USER(8): (nth 0 ’(a b c))
A
CL-USER(9): (nth 1 ’(a b c))
B
CL-USER(10): (nth 2 ’(a b c))
C
CL-USER(11): (nth 12 ’(a b c d e f g h i j k l m n o p))
M
Note that nth starts its indexing at zero (0), so (nth 0 ...) is equivalent to (first ...),
and (nth 1 ...) is equivalent to (second ...), etc.3.2. THE LIST AS A DATA STRUCTURE 29
3.2.2 The “Rest” of the Story
A very common operation in CL is to perform some operation on the first of a list, then
perform the same operation on each first of the rest of the list, repeating the procedure
until the end of the list, i.e. the Empty list, is reached. The function rest is very helpful
in such cases:
CL-USER(59): (rest ’(a b c))
(B C)
As you can see from this example, rest returns a list consisting of all but the first of its
argument.
3.2.3 The Empty List
The symbol NIL is defined by Common Lisp to be equivalent to the Empty List, (). NIL
also has the interesting property that its value is itself, which means that it will always
evaluate to itself, whether or not it is quoted. So NIL, ’NIL, and () all evaluate to the
Empty List, whose default printed representation is NIL:
CL-USER(14): nil
NIL
CL-USER(15): ’nil
NIL
CL-USER(16): ()
NIL
The function null can be used to test whether or not something is the Empty List:
CL-USER(17): (null ’(a b c))
NIL
CL-USER(18): (null nil)
T
CL-USER(19): (null ())
T
As you may have deduced from the above examples, the symbol T is CL’s default representation for “true.” As with NIL, T evaluates to itself.
3.2.4 Are You a List?
To test whether or not a particular object is a list, CL provides the function listp. Like
many other functions which end with the letter “p,” this function takes a single argument
and checks whether it meets certain criteria (in this case, whether it qualifies as a list).
These predicate functions ending in the letter “p” will always return either T or NIL:30 CHAPTER 3. THE CL LANGUAGE
CL-USER(20): (listp ’(pontiac cadillac chevrolet))
T
CL-USER(21): (listp 99)
NIL
CL-USER(22): (listp nil)
T
Note that (listp nil) returns T, since NIL is indeed a list (albeit the empty one).
3.2.5 The conditional If
Before continuing with a number of other basic list functions, we will cover the macro if,
which allows simple conditionals. If takes three arguments, a test-form, a then-form, and
an else-form. When an if form is evaluated, it first evaluates its test-form. If the form
returns non-NIL, it will evaluate the then-form, else it will evaluate the else-form. The
nesting of multiple if expressions is possible, but not advised; later we will cover other
constructs which are more appropriate for such cases.
Here are some simple examples using the if operator:
CL-USER(2): (if (> 3 4)
"yes"
"no")
"no"
CL-USER(3): (if (listp ’("Chicago" "Detroit" "Toronto"))
"it is a list"
"it ain’t a list")
"it is a list"
CL-USER(4): (if (listp 99)
"it is a list"
"it ain’t a list")
"it ain’t a list"
3.2.6 Length of a List
Normally you can use the function length to get the number of elements in a list as an
integer:
CL-USER(5): (length ’(gm ford chrysler volkswagen))
43.2. THE LIST AS A DATA STRUCTURE 31
CL-USER(6): (length nil)
0
The length function, as with most of Common Lisp, can itself be implemented in CL. Here
is a simplified version of an our-length function which illustrates how length might be
implemented:
(defun our-length (list)
(if (null list)
0
(+ (our-length (rest list)) 1)))
Note that the function uses the symbol list to name its argument, which is perfectly valid
as we discussed in section 3.1.4.
In English, this function says basically: “If the list is empty, its length is zero. Otherwise
its length is one greater than the length of its rest.” As with many functions which operate
on lists, this recursive definition is a natural way to express the length operation.
3.2.7 Member of a List
The member function will help you to determine whether a particular item is an element of
a particular list. Like many similar functions, member uses eql to test for equality, which is
one of the most basic equality functions in CL (see Section 3.8.4 for a discussion of equality
in CL). Eql basically means the two objects must be the same symbol, integer, or actual
object (i.e. the same address in memory).
Member takes two arguments: an item and a list. If the item is not in the list, it returns
NIL. Otherwise, it returns the rest of the list, starting from the found element:
CL-USER(7): (member ’dallas ’(boston san-francisco portland))
NIL
CL-USER(8): (member ’san-francisco ’(boston san-francisco portland))
(SAN-FRANCISCO PORTLAND)
As with length, we could define member using a function definition which is very close to
the English description of what the function is supposed to do
3
:
(defun our-member (elem list)
(if (null list)
nil
(if (eql elem (first list))
list
(our-member elem (rest list)))))
3
The use of the “nested” if statement in this example, while functionally correc
In English, you might read this function to say “If the list is empty, return NIL. Otherwise,
if the desired item is the same as the first of the list, return the entire list. Otherwise, do
the same thing on the rest of the list.”
Note that, for the purposes of any kind of logical operators, returning any non-NIL value
is “as good as” returning T. So the possible return-values of the member function are as good
as returning T or NIL as far as any logical operators are concerned.
3.2.8 Getting Part of a List
Subseq is a common function to use for returning a portion of a list (or actually any type
of Sequence). Subseq takes at least two arguments, a list and an integer indicating the
position to start from. It also takes an optional third argument, an integer indicating the
position to stop. Note that the position indicated by this third argument is not included in
the returned sub-list:
CL-USER(9): (subseq ’(a b c d) 1 3)
(B C)
CL-USER(10): (subseq ’(a b c d) 1 2)
(B)
CL-USER(11): (subseq ’(a b c d) 1)
(B C D)
Note also that the optional third argument in effect defaults to the length of the list.
3.2.9 Appending Lists
The function append takes any number of lists, and returns a new list which results from
appending them together. Like many CL functions, append does not side-effect, that is, it
simply returns a new list as a return-value, but does not modify its arguments in any way:
CL-USER(6): (setq my-slides ’(introduction welcome lists functions))
(INTRODUCTION WELCOME LISTS FUNCTIONS)
CL-USER(7): (append my-slides ’(numbers))
(INTRODUCTION WELCOME LISTS FUNCTIONS NUMBERS)
CL-USER(8): my-slides
(INTRODUCTION WELCOME LISTS FUNCTIONS)