From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Barry Margolin Newsgroups: gmane.emacs.help Subject: Re: list conversion Date: Tue, 06 May 2003 20:04:36 GMT Organization: Genuity Managed Services, Woburn, MA Sender: help-gnu-emacs-bounces+gnu-help-gnu-emacs=m.gmane.org@gnu.org Message-ID: References: NNTP-Posting-Host: main.gmane.org X-Trace: main.gmane.org 1052252518 17906 80.91.224.249 (6 May 2003 20:21:58 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Tue, 6 May 2003 20:21:58 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+gnu-help-gnu-emacs=m.gmane.org@gnu.org Tue May 06 22:21:56 2003 Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 19D8vu-0004bg-00 for ; Tue, 06 May 2003 22:21:02 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.10.13) id 19D8hE-00012B-02 for gnu-help-gnu-emacs@m.gmane.org; Tue, 06 May 2003 16:05:52 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!logbridge.uoregon.edu!arclight.uoregon.edu!enews.sgi.com!paloalto-snf1.gtei.net!mtvwca1-snh1.ops.genuity.net!crtntx1-snh1.gtei.net!news.gtei.net!paloalto-snr1.gtei.net.POSTED!not-for-mail Original-Newsgroups: gnu.emacs.help Mail-Copies-To: never X-Newsreader: trn 4.0-test72 (19 April 1999) Originator: barmar@genuity.net (Barry Margolin) Original-Lines: 29 Original-X-Trace: /KDWjZevYVCPSjRmppBOCJED/ovDCMHX62P6uicziO2l5WEUHctCKhDBtTwxVdeHbid95jHzWyL7!y+Dt5PleEoaONDXbrNNOix1A662QlyLWePqRisIvMETuYlB6miqoV7cmfmvYf4R0KvWQKyEhKGWd!MF5z9jrsAzVEaA== Original-X-Complaints-To: abuse@gte.net X-Abuse-Info: Please be sure to forward a copy of ALL headers X-Abuse-Info: Otherwise we will be unable to process your complaint properly Original-NNTP-Posting-Date: Tue, 06 May 2003 20:04:36 GMT Original-Distribution: world Original-Xref: shelby.stanford.edu gnu.emacs.help:112863 Original-To: help-gnu-emacs@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1b5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Help: List-Post: List-Subscribe: , List-Archive: List-Unsubscribe: , Errors-To: help-gnu-emacs-bounces+gnu-help-gnu-emacs=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.help:9358 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:9358 In article , Z. Huang wrote: >(defun list-conversion (arg) > (let ((l arg) (new-list ())) > (while l > (append new-list (list "" . (car l)))) > (setq l (cdr l)))) (defun list-conversion (list) (mapcar '(lambda (item) (cons "" item)) list)) Here's a version more like your original attempt: (defun list-conversion (list) (let ((l arg) (new-list '())) (while l (setq new-list (cons (cons "" (car l)))) (setq l (cdr l))) (nreverse new-list))) Note that you need to re-assign new-list each time through the loop; append creates a new list, but it doesn't change what new-list refers to. Also, you need to use cons, not list, to create something of the form (x . y). -- Barry Margolin, barry.margolin@level3.com Genuity Managed Services, a Level(3) Company, Woburn, MA *** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups. Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.