Jan Vroonhof <vroonhof(a)math.ethz.ch> writes:
(mapcar
(function
(lambda (x)
(if (not (and (boundp x) (symbol-value x)))
(setq vars (delq x vars))))) vars)))
Here is an easier one
(let ((lijst '(a b c)))
(mapcar
(lambda (x)
;; Make list shorter behind mapcar's back
(delete 'c lijst))
lijst))
The problem is this code in in mapcar1
if (LISTP (seq))
{
for (i = 0; i < leni; i++)
{
args[1] = XCAR (seq);
seq = XCDR (seq);
result = Ffuncall (2, args);
if (vals) vals[gcpro1.nvars++] = result;
}
}
It blindingly believes that XCDR(seq) will always be a cons cell,
although it calls user code which could have modified the list it is
iterating over.
Jan
P.S. What should this do?
(let ((lijst '(1 2 3))
(addme '(4 5 6)))
(mapcar (lambda (x)
;; Make list longer behing mapcar's back
(nconc lijst addme)
(setq addme nil)
x)
lijst))