help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: print out all members of a list


From: Andreas Röhler
Subject: Re: print out all members of a list
Date: Tue, 01 Mar 2011 19:39:16 +0100
User-agent: Mozilla/5.0 (X11; U; Linux i686; de; rv:1.9.1.11) Gecko/20100711 Thunderbird/3.0.6

Am 01.03.2011 14:10, schrieb Pascal J. Bourguignon:
Andreas Röhler<address@hidden>  writes:

Am 28.02.2011 16:20, schrieb ken:
(car '("one" "two" "three"))

prints out "one" ... the first of the list.  How to print out all
elements of the list (in order and with the double quotes around them?
I'm actually looking just to substitute something for "car" and not
write an entire function.  Or is there no such thing?

Thanks much.



and still a form delivering with doublequotes...

(let ((my-list (list "one" "two" "three")))
     (dolist (elem my-list)
   (insert (format "\n\"%s\"" elem))))

Why do you write broken code?

     (let ((my-list (list "o\"n\"e" "t\"wo" "th\\\"ree")))
        (dolist (elem my-list)
           (insert (format "\n\"%s\"" elem))))

     "o"n"e"
     "t"wo"
     "th\"ree"


Is it not easier to write code that works?

     (let ((my-list (list "o\"n\"e" "t\"wo" "th\\\"ree")))
        (dolist (elem my-list)
           (insert (format "\n%s" (prin1-to-string elem)))))

     "o\"n\"e"
     "t\"wo"
     "th\\\"ree"



Ok, thanks, interesting point.

From there `concat' read better for me

(let ((my-list (list "o\"n\"e" "t\"wo" "th\\\"ree")))
       (dolist (elem my-list)
          (insert (concat "\n" (prin1-to-string elem)))))

(?) :-)






reply via email to

[Prev in Thread] Current Thread [Next in Thread]