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: Reverse pop, return value Date: Tue, 17 Nov 2009 16:48:31 +0100 Message-ID: References: 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 1258472978 26446 80.91.229.12 (17 Nov 2009 15:49:38 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 17 Nov 2009 15:49:38 +0000 (UTC) Cc: help-gnu-emacs@gnu.org To: LanX Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Nov 17 16:49:30 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 1NAQJ4-0007Sp-Ok for geh-help-gnu-emacs@m.gmane.org; Tue, 17 Nov 2009 16:49:27 +0100 Original-Received: from localhost ([127.0.0.1]:38888 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NAQJ4-0006kG-Cc for geh-help-gnu-emacs@m.gmane.org; Tue, 17 Nov 2009 10:49:26 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NAQIa-0006hk-S9 for help-gnu-emacs@gnu.org; Tue, 17 Nov 2009 10:48:56 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NAQIW-0006cq-Dj for help-gnu-emacs@gnu.org; Tue, 17 Nov 2009 10:48:56 -0500 Original-Received: from [199.232.76.173] (port=57052 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NAQIW-0006ce-6b for help-gnu-emacs@gnu.org; Tue, 17 Nov 2009 10:48:52 -0500 Original-Received: from mail-yx0-f191.google.com ([209.85.210.191]:49527) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NAQIV-0001ib-SO for help-gnu-emacs@gnu.org; Tue, 17 Nov 2009 10:48:52 -0500 Original-Received: by yxe29 with SMTP id 29so130658yxe.14 for ; Tue, 17 Nov 2009 07:48:51 -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=0dciY7Ilx6C74R69VtgSjrMCIEGYkWxdjwfyP65bfaM=; b=dcrwq6z9gP4z6XymQHKvI94YGzcCXVCZy3qjuKTXKOSHsd9ulkqO/ZxZD91og/DNcn H5StVf14w9BjDkew0WseTjcIsJ0BWzNAh1bqY/b2mdjwm+E/JD8ijMBH1FAQPUGqnw7Z 7z2MzjbeZ34EA4bPHG1m6SF66VJ1lMGRADL5Y= 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=Fd+GAPCCniHAIRjNx84OmfNdfExd89rPtRSlrEWt8YrOzCd9OFAhD6fkQX+6OryFNz aNXk6ec75CY08FeJ6Q41qH7MybB3dFtW1ldcyP9232Bed8q9BbloGy9x9apwfN8O+gZi Wu7LE/XdrNe4doTvg5Cj0ag7KJ5S4yTGGJv6w= Original-Received: by 10.101.171.36 with SMTP id y36mr1624541ano.75.1258472931167; Tue, 17 Nov 2009 07:48:51 -0800 (PST) In-Reply-To: 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:69835 Archived-At: On Tue, Nov 17, 2009 at 4:32 PM, LanX wrote: > Hi > > I tried to realize a reverse pop which pops from the end of the list, > but the code get's "lengthy".... > > I need to define a local variable to hold the return value... is there > a more elegant way to do it? > > =C2=A0----------- M-x ielm > ELISP> (defun rpop (LIST) > =C2=A0 =C2=A0 =C2=A0 =C2=A0 "reverse pop" > =C2=A0 =C2=A0 =C2=A0 =C2=A0 (let > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0( (ret (car (last LIST))) ) > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(nbutlast LIST 1) > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0ret > =C2=A0 =C2=A0 =C2=A0 =C2=A0 ) > =C2=A0 =C2=A0 =C2=A0 ) prog1