From: Jakob Friis
Subject: lists
Date: 
Message-ID: <365A8260.E0729E81@cs.auc.dk>
Hello there

Does anybody know how to get the length of a list ? I am implementing a
small program in emacs-lisp and i have to retrieve the last element of a
list. I have tried (length) and (safe-length) but they both return some
control-character (^A).

Is there another way of retrieving the last element of a list ?

Greeting Jakob Friis

From: Martti Halminen
Subject: Re: lists
Date: 
Message-ID: <365AA416.402B@rm_spam_trap.dpe.fi>
Jakob Friis wrote:

> Does anybody know how to get the length of a list ? I am implementing a
> small program in emacs-lisp and i have to retrieve the last element of a
> list. I have tried (length) and (safe-length) but they both return some
> control-character (^A).
> 
> Is there another way of retrieving the last element of a list ?

(length '(a b c d)) => 4

(first (last '(a b c d))) => d

At least on GNU Emacs.


-- 
________________________________________________________________
    ^.          Martti Halminen
   / \`.        Design Power Europe Oy
  /   \ `.      Tekniikantie 12, FIN-02150 Espoo, Finland
 /\`.  \ |      Tel:+358 9 4354 2306, Fax:+358 9 455 8575
/__\|___\|      ······················@dpe.fi   http://www.dpe.fi
From: Gareth McCaughan
Subject: Re: lists
Date: 
Message-ID: <867lwlfemc.fsf@g.pet.cam.ac.uk>
Jakob Friis wrote:

> Does anybody know how to get the length of a list ? I am implementing a
> small program in emacs-lisp and i have to retrieve the last element of a
> list. I have tried (length) and (safe-length) but they both return some
> control-character (^A).

Eh? When I ask my emacs for (length '(a b c)) it tells me 3,
as I'd expect. What are you doing?

> Is there another way of retrieving the last element of a list ?

The function LAST returns the last cons cell of a list, and the
last element is the CAR of that.


Incidentally, I think there's a newsgroup specifically for discussion
of emacs. It might be a better place for questions on emacs lisp.
I'm afraid I've forgotten its name...

-- 
Gareth McCaughan       Dept. of Pure Mathematics & Mathematical Statistics,
·····@dpmms.cam.ac.uk  Cambridge University, England.
From: David Bakhash
Subject: Re: lists
Date: 
Message-ID: <cxjww4l2ij7.fsf@engc.bu.edu>
Gareth McCaughan <·····@dpmms.cam.ac.uk> writes:

> Jakob Friis wrote:
> Incidentally, I think there's a newsgroup specifically for discussion
> of emacs. It might be a better place for questions on emacs lisp.
> I'm afraid I've forgotten its name...

here are some pertinent ones:

comp.emacs.xemacs
comp.emacs
gnu.emacs.sources

dave