From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Thorsten Jolitz Newsgroups: gmane.emacs.help Subject: Re: 'length' function for lists and cons cells? Date: Thu, 21 Mar 2013 22:58:35 +0100 Message-ID: <871ub876us.fsf@gmail.com> References: <87620k7gwm.fsf@gmail.com> <87ip4kfrmf.fsf@rosalinde.fritz.box> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1363903139 4983 80.91.229.3 (21 Mar 2013 21:58:59 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 21 Mar 2013 21:58:59 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Mar 21 22:59:25 2013 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1UInW9-0000ly-BQ for geh-help-gnu-emacs@m.gmane.org; Thu, 21 Mar 2013 22:59:25 +0100 Original-Received: from localhost ([::1]:46160 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UInVm-000841-4n for geh-help-gnu-emacs@m.gmane.org; Thu, 21 Mar 2013 17:59:02 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:59834) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UInVc-00083w-07 for help-gnu-emacs@gnu.org; Thu, 21 Mar 2013 17:58:52 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UInVa-0007ii-M3 for help-gnu-emacs@gnu.org; Thu, 21 Mar 2013 17:58:51 -0400 Original-Received: from plane.gmane.org ([80.91.229.3]:56221) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UInVa-0007hy-Fp for help-gnu-emacs@gnu.org; Thu, 21 Mar 2013 17:58:50 -0400 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1UInVu-0000aq-ID for help-gnu-emacs@gnu.org; Thu, 21 Mar 2013 22:59:10 +0100 Original-Received: from g231234180.adsl.alicedsl.de ([92.231.234.180]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 21 Mar 2013 22:59:10 +0100 Original-Received: from tjolitz by g231234180.adsl.alicedsl.de with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 21 Mar 2013 22:59:10 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 29 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: g231234180.adsl.alicedsl.de User-Agent: Gnus/5.130002 (Ma Gnus v0.2) Emacs/24.2 (gnu/linux) Cancel-Lock: sha1:X7+F3I4pRKbXYeVbhcg34kjjD1k= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.91.229.3 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:89641 Archived-At: Stephen Berman writes: >> which function could I use when I map an alist e.g. with dolist, that >> contains both types of associations as shown below: cons cells, or lists >> with 3 or more elements? >> >> 'length' doesn't work on cons cells: > > Since a cons cells always contains exactly two members (its car and its > cdr), why do you want to call a function to find its length? actually I'm looking for a way to distinguish between cons cells and regular lists to avoid the errors when mapping an alist that contains both with functions that work only on one of them, using 'length' was just a hack. I would have thought that 'consp' might be the right function, but: ,----------------------- | (consp '("a" "b" "c")) | t | | (consp '("a" . "c")) | t `----------------------- -- cheers, Thorsten