[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Basic questions about elisp
From: |
Barry Margolin |
Subject: |
Re: Basic questions about elisp |
Date: |
Fri, 06 Nov 2009 00:06:16 -0500 |
User-agent: |
MT-NewsWatcher/3.5.3b3 (Intel Mac OS X) |
In article <87iqdpdog1.fsf@galatea.local>,
pjb@informatimago.com (Pascal J. Bourguignon) wrote:
> Francis Moreau <francis.moro@gmail.com> writes:
>
> > Hello,
> >
> > I'm trying to learn elisp and have a couple of basic questions.
> >
> > I'm iterating over a list using dotimes, but in the body of dotimes,
> dolist dolist
>
> > the list can mutate. For example I have:
> >
> > (dolist (elt lst)
> > ;; some codes
> > (nconc lst '(2)))
>
> This is an infinite loop. It will break when the program runs out of
> memory.
It also modifies a literal, which modifies the function itself
(resulting in a circular list of (2 2 2 2 ...)). Change that nconc to:
(nconc lst (list 2))
to avoid that.
>
>
> > This adds/appends a new element to 'lst' list. It looks like 'dotimes'
> dolist
> > doesn't like it.
>
> If you are not careful, you won't be able to program...
>
>
> > I also need to iterate over elements of a vector. I basically use a
> > 'while' loop as above. Is there any helper to do that, I looked at
> > "(elisp) Sequences Arrays Vectors" but found nothing appropriate.
>
> (require 'cl)
> (loop for element in list do (something element))
> (loop for element across vector do (something element))
>
>
> > And finally, is it the good place to ask such questions about elisp ?
>
> Yes, it's right here.
--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***
- Re: Basic questions about elisp, (continued)
- Re: Basic questions about elisp, Francis Moreau, 2009/11/08
- Re: Basic questions about elisp, tomas, 2009/11/08
- Re: Basic questions about elisp, Pascal J. Bourguignon, 2009/11/08
- Re: Basic questions about elisp, Francis Moreau, 2009/11/09
- Re: Basic questions about elisp, Joost Kremers, 2009/11/10
- Re: Basic questions about elisp, Francis Moreau, 2009/11/10
- Re: Basic questions about elisp, David Kastrup, 2009/11/10
Re: Basic questions about elisp,
Barry Margolin <=