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 11:24:37 -0700 (PDT)
User-agent: G2/1.0

This is my mockup:

(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)

But why does my test-cases return '(a b 1 2) all the time? The first
should return (a b) and second (1 2).
I have tried edebugging it but because mapcar is a builtin I didn't
get any help that way.

/Nordlöw


reply via email to

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