From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: LanX Newsgroups: gmane.emacs.help Subject: Reverse pop, return value Date: Tue, 17 Nov 2009 07:32:53 -0800 (PST) Organization: http://groups.google.com Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: ger.gmane.org 1258472463 24421 80.91.229.12 (17 Nov 2009 15:41:03 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 17 Nov 2009 15:41:03 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Nov 17 16:40:56 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 1NAQAq-00030D-01 for geh-help-gnu-emacs@m.gmane.org; Tue, 17 Nov 2009 16:40:56 +0100 Original-Received: from localhost ([127.0.0.1]:51794 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NAQAp-0001B5-Fe for geh-help-gnu-emacs@m.gmane.org; Tue, 17 Nov 2009 10:40:55 -0500 Original-Path: news.stanford.edu!usenet.stanford.edu!postnews.google.com!w19g2000yqk.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 32 Original-NNTP-Posting-Host: 188.97.70.67 Original-X-Trace: posting.google.com 1258471973 30694 127.0.0.1 (17 Nov 2009 15:32:53 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: Tue, 17 Nov 2009 15:32:53 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: w19g2000yqk.googlegroups.com; posting-host=188.97.70.67; posting-account=W9fpQwoAAADZYmkl-8sXk1VPxG3rq-Pd User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux i686; de; rv:1.9.0.14) Gecko/2009090216 Ubuntu/8.10 (intrepid) Firefox/3.0.14, gzip(gfe), gzip(gfe) Original-Xref: news.stanford.edu gnu.emacs.help:174759 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:69832 Archived-At: 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? ----------- M-x ielm ELISP> (defun rpop (LIST) "reverse pop" (let ( (ret (car (last LIST))) ) (nbutlast LIST 1) ret ) ) rpop ELISP> (setq list '(a b c d e f g h i j)) (a b c d e f g h i j) ELISP> (rpop list) j ELISP> (rpop list) i ELISP> (rpop list) h ------------- There must be a technique to simplify this !?! Thanx Rolf