From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Lennart Borgman Newsgroups: gmane.emacs.help Subject: Re: Basic questions about elisp Date: Thu, 5 Nov 2009 12:50:29 +0100 Message-ID: References: <1e9f8449-09ec-4a84-a332-9f05fadb8aa3@z41g2000yqz.googlegroups.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1257421900 1127 80.91.229.12 (5 Nov 2009 11:51:40 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 5 Nov 2009 11:51:40 +0000 (UTC) Cc: help-gnu-emacs@gnu.org To: Francis Moreau Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Nov 05 12:51:33 2009 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 1N60sF-0008Ir-Ap for geh-help-gnu-emacs@m.gmane.org; Thu, 05 Nov 2009 12:51:31 +0100 Original-Received: from localhost ([127.0.0.1]:42145 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N60sE-0004Ql-PK for geh-help-gnu-emacs@m.gmane.org; Thu, 05 Nov 2009 06:51:30 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1N60rg-0004QW-5Q for help-gnu-emacs@gnu.org; Thu, 05 Nov 2009 06:50:56 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1N60ra-0004Os-QU for help-gnu-emacs@gnu.org; Thu, 05 Nov 2009 06:50:55 -0500 Original-Received: from [199.232.76.173] (port=58728 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N60ra-0004Ok-Jc for help-gnu-emacs@gnu.org; Thu, 05 Nov 2009 06:50:50 -0500 Original-Received: from mail-yx0-f191.google.com ([209.85.210.191]:63992) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1N60ra-0005a2-4k for help-gnu-emacs@gnu.org; Thu, 05 Nov 2009 06:50:50 -0500 Original-Received: by yxe29 with SMTP id 29so7704836yxe.14 for ; Thu, 05 Nov 2009 03:50:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :from:date:message-id:subject:to:cc:content-type :content-transfer-encoding; bh=mP3g+lST2nxUMXqym78sq/AyW5SHXheD/gOM9qwPAao=; b=VkkHRrMGLwhLv7+tKwbIkbKEuPcLmLYhjnPt0DV66AEIyc4lwinurTwdfozKN3B92q 9dg4EKZj3xBomqv4dtSQ36ftH6XZAmnDd7v0Yok4PfjI41x+ojmwyZIldB8yqBoMDKO6 PUFFWX0jg6A2xkB68d3uQ/ykgPFkpQ0CC8z5M= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type:content-transfer-encoding; b=iIw1R9XzJqXlT2DQFODpPBbX/zci8ZulJOLt+Lj9UlgPYnbDiYXdF0wKHui72V9Eqo xxAYj6xDZOYh5/2LwzRT1XJ6r7jsU1mWMNTyqgVvYIlrloc/vuC42tXCwkKo9Lku9ikn zDfKJGZ/tzHjR5r9PqyemaTLIi1HbMeF743Mc= Original-Received: by 10.100.225.2 with SMTP id x2mr2021301ang.196.1257421849102; Thu, 05 Nov 2009 03:50:49 -0800 (PST) In-Reply-To: <1e9f8449-09ec-4a84-a332-9f05fadb8aa3@z41g2000yqz.googlegroups.com> X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) 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:69486 Archived-At: On Thu, Nov 5, 2009 at 12:13 PM, Francis Moreau wr= ote: > 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, > the list can mutate. For example I have: > > =C2=A0(dolist (elt lst) > =C2=A0 =C2=A0;; some codes > =C2=A0 =C2=A0(nconc lst '(2))) > > This adds/appends a new element to 'lst' list. It looks like 'dotimes' > doesn't like it. > > So I eventually wrote it like this > > =C2=A0 =C2=A0(setq i 0) > =C2=A0 =C2=A0(while (< i (length lst)) > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0;; some codes > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(x-nconc lst '(2)))) > =C2=A0 =C2=A0 =C2=A0(setq i (1+ i))) > > which is a bit ugly, is there another way to do that ? It is much easier to answer if you define exactly what you want to do when lst grows.