[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: use of mapcan
- To: clisp-list@ma2s2.mathematik.uni-karlsruhe.de
- Subject: Re: use of mapcan
- From: Bernt Nilsson <bkn@ida.liu.se>
- Date: Thu, 23 Feb 95 09:31:23 +0100
- Cc: dxs@evolving.com
> i have a question regarding mapcan used as a filter. if i want to avoid
> possible problems of side effects can i just return a cons containing
> the value i want to keep? for example
> (defun x (a) (if (keep a) (cons a nil) nil))
> and
> (mapcan #'x '(a b c d)).
> will this avoid possible problems?
> thanks,
> dan stanger
Yes, the sideeffect of mapcan is limited to the toplevel conses.
But if the thing you want to filter is a sequence, why not use
"remove-if-not"? ex;
(remove-if-not #'numberp '(a 17 42 b c 97 d e f))
-- Bernt