(cddr '(when (> x 10) (print x))) ==> ((PRINT X))
143
Thus, MAPLIST
is the more primitive of the two functions—if you had only MAPLIST
, you could build MAPCAR
on top of it, but you couldn't build MAPLIST
on top of MAPCAR
.
144
In Lisp dialects that didn't have filtering functions like REMOVE
, the idiomatic way to filter a list was with MAPCAN
.
(mapcan #'(lambda (x) (if (= x 10) nil (list x))) list) === (remove 10 list)
145
It's possible to build a chain of cons cells where the CDR
of the last cons cell isn't NIL
but some other atom. This is called a
146
It may seem that the NSUBST
family of functions can and in fact does modify the tree in place. However, there's one edge case: when the 'tree' passed is, in fact, an atom, it can't be modified in place, so the result of NSUBST
will be a different object than the argument: (nsubst 'x 'y 'y) X
.
147
UNION
takes only one element from each list, but if either list contains duplicate elements, the result may also contain duplicates.
148
It's also possible to directly SETF SYMBOL-PLIST
. However, that's a bad idea, as different code may have added different properties to the symbol's plist for different reasons. If one piece of code clobbers the symbol's whole plist, it may break other code that added its own properties to the plist.
149
Macro parameter lists do support one parameter type, &environment
parameters, which DESTRUCTURING-BIND
doesn't. However, I didn't discuss that parameter type in Chapter 8, and you don't need to worry about it now either.
150
When a &whole
parameter is used in a macro parameter list, the form it's bound to is the whole macro form, including the name of the macro.
151
Note, however, that while the Lisp reader knows how to skip comments, it completely skips them. Thus, if you use READ
to read in a configuration file containing comments and then use PRINT
to save changes to the data, you'll lose the comments.
152
By default OPEN
uses the default character encoding for the operating system, but it also accepts a keyword parameter, :external-format
, that can pass implementation-defined values that specify a different encoding. Character streams also translate the platform- specific end-of-line sequence to the single character #Newline
.
153
The type (unsigned-byte 8)
indicates an 8-bit byte; Common Lisp 'byte' types aren't a fixed size since Lisp has run at various times on architectures with byte sizes from 6 to 9 bits, to say nothing of the PDP-10, which had individually addressable variable-length bit fields of 1 to 36 bits.
154
In general, a stream is either a character stream or a binary stream, so you can't mix calls to READ-BYTE
and READ-CHAR
or other character-based read functions. However, some implementations, such as Allegro, support so-called bivalent streams, which support both character and binary I/O.