help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Wanted: mapcar() without nils


From: Nordlöw
Subject: Re: Wanted: mapcar() without nils
Date: Sat, 13 Jun 2009 12:45:06 -0700 (PDT)
User-agent: G2/1.0

Oopps, my mistake got a parenthesis wrong...

Now it works:

(defun extract-elements (pred seq)
  "Extract a copy of SEQ containing all elements fullfilling
PRED."
  (delq nil (mapcar `(lambda (elm) (when (,pred elm) elm)) seq)))
;; Use: (extract-elements 'symbolp '(a b 1 2)) => '(a b)
;; Use: (extract-elements 'numberp '(a b 1 2)) => '(1 2)

Thanks,
Nordlöw


reply via email to

[Prev in Thread] Current Thread [Next in Thread]