From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Marc Tfardy Newsgroups: gmane.emacs.help Subject: Re: Problem with position and find (cl) Date: Sat, 21 Jun 2008 12:38:43 +0200 Message-ID: <6c441mF3e1foaU1@mid.individual.net> References: <6c2bb4F3dibi5U1@mid.individual.net> <6c2gf4F3eltftU1@mid.individual.net> <87hcbng8z6.fsf@sophokles.streitblatt.de> <6c4268F3eh5teU1@mid.individual.net> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1214045347 1580 80.91.229.12 (21 Jun 2008 10:49:07 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 21 Jun 2008 10:49:07 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Jun 21 12:49:52 2008 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1KA0fH-0004eE-Vv for geh-help-gnu-emacs@m.gmane.org; Sat, 21 Jun 2008 12:49:52 +0200 Original-Received: from localhost ([127.0.0.1]:52792 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KA0eS-0005pn-Me for geh-help-gnu-emacs@m.gmane.org; Sat, 21 Jun 2008 06:49:00 -0400 Original-Path: news.stanford.edu!headwall.stanford.edu!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 64 Original-X-Trace: individual.net UtecuvJSWJiE6xZLpA/KLAuja1AqOZ5ZdakwGid9YIw1KaCbs7 Cancel-Lock: sha1:RVAjJOkh7pwi6fFtwALMosLH/Uw= User-Agent: Thunderbird 2.0.0.14 (Windows/20080421) In-Reply-To: <6c4268F3eh5teU1@mid.individual.net> Original-Xref: news.stanford.edu gnu.emacs.help:159670 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:55024 Archived-At: Marc Tfardy schrieb: > Thierry Volpiatto schrieb: >> Florian Beck writes: >> >>> Marc Tfardy writes: >>> >>>> Marc Tfardy schrieb: >>>>> I try with: >>>>> (member '(2) '((1) (2) (3) (4))) >>> `member' tests the components: ›2‹ ist always equal (in the sense of >>> »eq«) to ›2‹ >>> >>> Compare: >>> >>> (memq '(2) '((1) (2) (3) (4))) >>> (eq 2 2) >>> (eq '(2) '(2)) >>> >>>>> and this gives a expectet results ((2) (3) (4)), but: >>>>> (find '(2) '((1) (2) (3) (4))) >>>>> or >>>>> (position '(2) '((1) (2) (3) (4))) >>>>> >>>>> returns nil. Why? >>> Because the first and the second »(2)« have the same components but are >>> *different* lists. >>> >>>> But this works: >>>> >>>> (position '(2) '((1) (2) (3) (4)) :test (lambda (x y) (eq (car x) (car >>>> y)))) >>>> > >> position default test is 'eq, try 'equal > > Thanks! It works with equal. But I have another problem. > find (and find-if) returns only first match. Is there another > function that returns all matched elements. Some example: > > (find-if-all (lambda (x) (if (eq (nth 2 x) 'byte) t nil)) '((1.1 "x" > int) (2.2 "y" byte) (3.3 "q" int) (4.4 "b" byte) (5.5 "a" float))) > > should returns: > ((2.2 "y" byte) (4.4 "b" byte)) > > I found in cl-*.el nothing like this. Any hints? I found some "strange" solution: (remove-if-not (lambda (x) (if (eq (nth 2 x) 'byte) t nil)) '((1.1 "x" int) (2.2 "y" byte) (3.3 "q" int) (4.4 "b" byte) (5.5 "a" float))) but with: (fset 'find-all 'remove-if-not) or: (defalias 'find-all 'remove-if-not) (a propos - what is the right method?) - it looks good and works like expected. Marc