* print out all members of a list
@ 2011-02-28 15:20 ken
2011-02-28 16:50 ` Teemu Likonen
` (5 more replies)
0 siblings, 6 replies; 29+ messages in thread
From: ken @ 2011-02-28 15:20 UTC (permalink / raw)
To: GNU Emacs List
(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.
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: print out all members of a list
2011-02-28 15:20 print out all members of a list ken
@ 2011-02-28 16:50 ` Teemu Likonen
2011-02-28 17:21 ` ken
` (4 subsequent siblings)
5 siblings, 0 replies; 29+ messages in thread
From: Teemu Likonen @ 2011-02-28 16:50 UTC (permalink / raw)
To: gebser; +Cc: GNU Emacs List
* 2011-02-28 10:20 (-0500), ken wrote:
> (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?
CAR doesn't print anything, it _returns_ a value. I'm not sure what you
mean, maybe this:
(identity '("one" "two" "three"))
IDENTITY just returns its argument. If you need some kind of
pretty-printing you could try PP function.
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: print out all members of a list
2011-02-28 15:20 print out all members of a list ken
2011-02-28 16:50 ` Teemu Likonen
@ 2011-02-28 17:21 ` ken
2011-02-28 18:25 ` print out all members of a list, v.1.0 ken
` (3 more replies)
[not found] ` <mailman.0.1298913700.1451.help-gnu-emacs@gnu.org>
` (3 subsequent siblings)
5 siblings, 4 replies; 29+ messages in thread
From: ken @ 2011-02-28 17:21 UTC (permalink / raw)
To: gebser; +Cc: GNU Emacs List
On 02/28/2011 10:20 AM ken wrote:
> (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.
>
I've been criticized for my elisp terminology-- and properly so--, so
let me rephrase:
(car '("one" "two" "three"))
returns a string consisting of the first element (?) of the list. Is
there an elisp function which either (1) returns one string for each
element of the list or (2) returns one string containing all elements of
the list?
E.g.:
(1) "one" "two" "three"
or
(2) "onetwothree"
preferably (1).
Thanks again.
P.S. It seems strange that elisp has so many ways to manipulate lists,
but doesn't seem to have this very simple functionality.
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: print out all members of a list, v.1.0
2011-02-28 17:21 ` ken
@ 2011-02-28 18:25 ` ken
2011-02-28 18:32 ` print out all members of a list Thierry Volpiatto
` (2 subsequent siblings)
3 siblings, 0 replies; 29+ messages in thread
From: ken @ 2011-02-28 18:25 UTC (permalink / raw)
Cc: GNU Emacs List
Ughhh. Finally, after reading many, many info pages and running a dozen
or so google searches and reading four or five that many web pages over
the past couple days, I found what I was after... mapconcat. Still then
it took a bit of reading error messages and playing around with syntax,
but it's working. All that for one line of code!
I've programmed in a lot of languages over the decades, but elisp
definitely has the steepest learning curve... prolly cuz it's so
hodge-podgey. Well, this isn't a discussion I have time for. I'm just
sayin', if not for emacs, elisp would be gone... and it might be gone
anyway in a generation or two. I'll leave it to those who know the
language better than I to if/how to prevent that happening.
On 02/28/2011 12:21 PM ken wrote:
> On 02/28/2011 10:20 AM ken wrote:
>> (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.
>>
>
> I've been criticized for my elisp terminology-- and properly so--, so
> let me rephrase:
>
> (car '("one" "two" "three"))
>
> returns a string consisting of the first element (?) of the list. Is
> there an elisp function which either (1) returns one string for each
> element of the list or (2) returns one string containing all elements of
> the list?
>
> E.g.:
>
> (1) "one" "two" "three"
>
> or
>
> (2) "onetwothree"
>
> preferably (1).
>
>
> Thanks again.
>
>
> P.S. It seems strange that elisp has so many ways to manipulate lists,
> but doesn't seem to have this very simple functionality.
>
>
>
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: print out all members of a list
2011-02-28 17:21 ` ken
2011-02-28 18:25 ` print out all members of a list, v.1.0 ken
@ 2011-02-28 18:32 ` Thierry Volpiatto
2011-02-28 20:26 ` PJ Weisberg
[not found] ` <mailman.5.1298917525.1451.help-gnu-emacs@gnu.org>
3 siblings, 0 replies; 29+ messages in thread
From: Thierry Volpiatto @ 2011-02-28 18:32 UTC (permalink / raw)
To: help-gnu-emacs
ken <gebser@mousecar.com> writes:
> On 02/28/2011 10:20 AM ken wrote:
>> (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.
>>
>
> I've been criticized for my elisp terminology-- and properly so--, so
> let me rephrase:
>
> (car '("one" "two" "three"))
>
> returns a string consisting of the first element (?) of the list. Is
> there an elisp function which either (1) returns one string for each
> element of the list or (2) returns one string containing all elements of
> the list?
>
> E.g.:
>
> (1) "one" "two" "three"
(loop for i in '("one" "two" "three") do (princ (concat "\"" i "\"" " ")))
> or
>
> (2) "onetwothree"
(mapconcat 'identity '("one" "two" "three") " ")
==>"one two three"
> preferably (1).
>
>
> Thanks again.
>
>
> P.S. It seems strange that elisp has so many ways to manipulate lists,
> but doesn't seem to have this very simple functionality.
Because "one" "two" "three" is unusable in code if not in a container.
(i.e it is three differents objects, but not one)
--
A+ Thierry
Get my Gnupg key:
gpg --keyserver pgp.mit.edu --recv-keys 59F29997
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: print out all members of a list
2011-02-28 17:21 ` ken
2011-02-28 18:25 ` print out all members of a list, v.1.0 ken
2011-02-28 18:32 ` print out all members of a list Thierry Volpiatto
@ 2011-02-28 20:26 ` PJ Weisberg
[not found] ` <mailman.5.1298917525.1451.help-gnu-emacs@gnu.org>
3 siblings, 0 replies; 29+ messages in thread
From: PJ Weisberg @ 2011-02-28 20:26 UTC (permalink / raw)
To: gebser; +Cc: GNU Emacs List
On 2/28/11, ken <gebser@mousecar.com> wrote:
> On 02/28/2011 10:20 AM ken wrote:
>> (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.
>>
>
> I've been criticized for my elisp terminology-- and properly so--, so
> let me rephrase:
>
> (car '("one" "two" "three"))
>
> returns a string consisting of the first element (?) of the list. Is
> there an elisp function which either (1) returns one string for each
> element of the list or (2) returns one string containing all elements of
> the list?
>
> E.g.:
>
> (1) "one" "two" "three"
>
> or
>
> (2) "onetwothree"
>
> preferably (1).
I'm not sure what (1) would actually *mean*, since a list of three
strings is what you already have, but if you did want to print each of
them out, then perhaps something like
(mapc 'insert '("one" "two" "three"))
-PJ
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: print out all members of a list, v.1.0
[not found] ` <mailman.5.1298917525.1451.help-gnu-emacs@gnu.org>
@ 2011-02-28 21:32 ` Tim X
2011-03-01 5:48 ` Pascal J. Bourguignon
2011-03-01 6:02 ` rusi
2 siblings, 0 replies; 29+ messages in thread
From: Tim X @ 2011-02-28 21:32 UTC (permalink / raw)
To: help-gnu-emacs
ken <gebser@mousecar.com> writes:
> Ughhh. Finally, after reading many, many info pages and running a dozen
> or so google searches and reading four or five that many web pages over
> the past couple days, I found what I was after... mapconcat. Still then
> it took a bit of reading error messages and playing around with syntax,
> but it's working. All that for one line of code!
>
> I've programmed in a lot of languages over the decades, but elisp
> definitely has the steepest learning curve... prolly cuz it's so
> hodge-podgey. Well, this isn't a discussion I have time for. I'm just
> sayin', if not for emacs, elisp would be gone... and it might be gone
> anyway in a generation or two. I'll leave it to those who know the
> language better than I to if/how to prevent that happening.
>
>
Hi Ken,
Elisp is what actually differentiates Emacs from other editors.
if you have programming experience, but finding elisp difficult due to
syntax and a feeling it is very "hodge-podge", I would strongly
recommend you read the "Introduction to Emacs Lisp" which is bundled
with emacs (from version 23 onwards) or from the gnu website.
The document states it is targeted at non-programmers, which may put you
off. However, elisp (and lisp in general) has some conceptual
differences that can make it harder than necessary if you are use to
other more procedural languages like C or one of the scripting
languages. Some of the terminology will seem very alien (i.e. car, cdr
etc) but are in fact quite simple conceptually. Understanding the REPL
is important.
One reason I think you may find this useful is that a common property of
lisp languages is a very small, simple and consistent syntax. As you
have found this a problem, I'm guessing you may be missing some basic
grass root concepts underlying how it works. Once you have these
concepts and adjust to the slightly different lisp development model
(i.e. using the repl to experiment and build up small bits of code),
there is a good chance you will feel very comfortable with the language
and will frequently find yourself knocking up small elisp functions to
automate tasks.
Once your comfortable with the langauge, the biggest challenge you will
face is just knowing what funnctions already exist. This is where
getting comfortable with the emacs help, apropos and manual helps. Most
of the time, you can achieve what you want just by glueing together
already existing lower level functions.
HTH
Tim
--
tcross (at) rapttech dot com dot au
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: print out all members of a list
[not found] ` <mailman.0.1298913700.1451.help-gnu-emacs@gnu.org>
@ 2011-03-01 5:41 ` Pascal J. Bourguignon
0 siblings, 0 replies; 29+ messages in thread
From: Pascal J. Bourguignon @ 2011-03-01 5:41 UTC (permalink / raw)
To: help-gnu-emacs
ken <gebser@mousecar.com> writes:
> On 02/28/2011 10:20 AM ken wrote:
>> (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.
>>
>
> I've been criticized for my elisp terminology-- and properly so--, so
> let me rephrase:
>
> (car '("one" "two" "three"))
>
> returns a string consisting of the first element (?) of the list. Is
> there an elisp function which either (1) returns one string for each
> element of the list or
Not in emacs lisp, since emacs lisp function can return only ONE result.
They cannot return several results.
Even in Common Lisp which can return several results, there is an
implementation defined on the maximum number of results a function can
return (which must be at least 20, but can also be at most 20 even if
it's often bigger) so you cannot in general return one result per
element of a list, since lists are not limited in length apart from the
memory available.
> (2) returns one string containing all elements of
> the list?
What's wrong with the list itself?
It already contains all the elements of the list,
and if they're strings as your list seems to contain, it already
contains all the elements of the list (itself) as strings.
In anycase, if you don't mind the parentheses, you can get the list
represented as a string with:
(let ((list '("one" "two" "tree")))
(prin1-to-string list))
--> "(\"one\" \"two\" \"tree\")"
You can also trivially remove the parentheses:
(let ((list '("one" "two" "tree")))
(substring (prin1-to-string list) 1 -1))
--> "\"one\" \"two\" \"tree\""
Now, if the elements of the list are not strings, and you want them to
be strings, you can do so with:
(let ((list '(one 2 [t h r e e])))
(mapcar (function prin1-to-string) list))
--> ("one" "2" "[t h r e e]")
and if you still insist to have the result as a single string:
(let ((list '(one 2 [t h r e e])))
(substring (prin1-to-string (mapcar (function prin1-to-string) list)) 1 -1))
--> "\"one\" \"2\" \"[t h r e e]\""
But I repeat, there's little point in converting lists into strings,
since it's so much easier to process data when it's structured into
lists, than when it's mere characters in a string.
> P.S. It seems strange that elisp has so many ways to manipulate lists,
> but doesn't seem to have this very simple functionality.
Yes. Think about it!
--
__Pascal Bourguignon__ http://www.informatimago.com/
A bad day in () is better than a good day in {}.
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: print out all members of a list, v.1.0
[not found] ` <mailman.5.1298917525.1451.help-gnu-emacs@gnu.org>
2011-02-28 21:32 ` print out all members of a list, v.1.0 Tim X
@ 2011-03-01 5:48 ` Pascal J. Bourguignon
2011-03-01 6:02 ` rusi
2 siblings, 0 replies; 29+ messages in thread
From: Pascal J. Bourguignon @ 2011-03-01 5:48 UTC (permalink / raw)
To: help-gnu-emacs
ken <gebser@mousecar.com> writes:
> Ughhh. Finally, after reading many, many info pages and running a dozen
> or so google searches and reading four or five that many web pages over
> the past couple days, I found what I was after... mapconcat. Still then
> it took a bit of reading error messages and playing around with syntax,
> but it's working. All that for one line of code!
>
> I've programmed in a lot of languages over the decades, but elisp
> definitely has the steepest learning curve... prolly cuz it's so
> hodge-podgey.
It is not. Just read a lisp programming course.
You can in general use Common Lisp books and tutorials to good effect,
since emacs lisp is close enough to Common Lisp (even if emacs lisp has
some limitations that you need to understand). The point is that there
is much more material for Common Lisp studying than for emacs lisp.
http://www.gnu.org/software/emacs/emacs-lisp-intro/
http://www.gnu.org/software/emacs/manual/html_mono/elisp.html
http://cliki.net/Online%20Tutorial
http://www.cliki.net/Lisp%20books
I would advise these books:
http://www-2.cs.cmu.edu/~dst/LispBook/
http://www.gigamonkeys.com/book/
> Well, this isn't a discussion I have time for. I'm just
> sayin', if not for emacs, elisp would be gone... and it might be gone
> anyway in a generation or two. I'll leave it to those who know the
> language better than I to if/how to prevent that happening.
Outside of gnu emacs (and forks), indeed there are better lisps. I
prefer Common Lisp, but some kind of scheme is even considered to
replace emacs lisp.
But it would not change your problem, since these languages are all
lisps, they behave at taste mostly the same. Notably for fundamental
notions such as lists.
--
__Pascal Bourguignon__ http://www.informatimago.com/
A bad day in () is better than a good day in {}.
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: print out all members of a list, v.1.0
[not found] ` <mailman.5.1298917525.1451.help-gnu-emacs@gnu.org>
2011-02-28 21:32 ` print out all members of a list, v.1.0 Tim X
2011-03-01 5:48 ` Pascal J. Bourguignon
@ 2011-03-01 6:02 ` rusi
2011-03-02 4:51 ` Barry Margolin
2 siblings, 1 reply; 29+ messages in thread
From: rusi @ 2011-03-01 6:02 UTC (permalink / raw)
To: help-gnu-emacs
On Feb 28, 11:25 pm, ken <geb...@mousecar.com> wrote:
> Ughhh. Finally, after reading many, many info pages and running a dozen
> or so google searches and reading four or five that many web pages over
> the past couple days, I found what I was after... mapconcat. Still then
> it took a bit of reading error messages and playing around with syntax,
> but it's working. All that for one line of code!
Learning a new language is often most frustrating in the simplest
aspects.
Use this list/group earlier next time!
>
> I've programmed in a lot of languages over the decades, but elisp
> definitely has the steepest learning curve... prolly cuz it's so
> hodge-podgey.
yes it is. emacs lisp became obsolete when scheme and common lisp came
out -- which is about 30 years ago. And its still the most commonly
used lisp. Go figure!
> Well, this isn't a discussion I have time for. I'm just
> sayin', if not for emacs, elisp would be gone... and it might be gone
> anyway in a generation or two. I'll leave it to those who know the
> language better than I to if/how to prevent that happening.
>
> On 02/28/2011 12:21 PM ken wrote:
>
> > On 02/28/2011 10:20 AM ken wrote:
> >> (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.
>
> > I've been criticized for my elisp terminology-- and properly so--, so
> > let me rephrase:
>
> > (car '("one" "two" "three"))
>
> > returns a string consisting of the first element (?) of the list. Is
> > there an elisp function which either (1) returns one string for each
> > element of the list or (2) returns one string containing all elements of
> > the list?
>
> > E.g.:
>
> > (1) "one" "two" "three"
>
> > or
>
> > (2) "onetwothree"
>
> > preferably (1).
>
> > Thanks again.
>
> > P.S. It seems strange that elisp has so many ways to manipulate lists,
> > but doesn't seem to have this very simple functionality.
>
>
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: print out all members of a list
2011-02-28 15:20 print out all members of a list ken
` (2 preceding siblings ...)
[not found] ` <mailman.0.1298913700.1451.help-gnu-emacs@gnu.org>
@ 2011-03-01 11:33 ` Andreas Röhler
2011-03-01 11:44 ` Andreas Röhler
[not found] ` <mailman.5.1298979610.15512.help-gnu-emacs@gnu.org>
5 siblings, 0 replies; 29+ messages in thread
From: Andreas Röhler @ 2011-03-01 11:33 UTC (permalink / raw)
To: help-gnu-emacs
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.
>
>
Hi,
I like `dolist'
eval this
(let ((my-list (list "one" "two" "three")))
(dolist (elem my-list)
(insert (concat "\nHere I am!: " elem))))
HTH
Andreas
--
https://code.launchpad.net/~a-roehler/python-mode/python-mode-components
https://code.launchpad.net/s-x-emacs-werkstatt/
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: print out all members of a list
2011-02-28 15:20 print out all members of a list ken
` (3 preceding siblings ...)
2011-03-01 11:33 ` Andreas Röhler
@ 2011-03-01 11:44 ` Andreas Röhler
[not found] ` <mailman.5.1298979610.15512.help-gnu-emacs@gnu.org>
5 siblings, 0 replies; 29+ messages in thread
From: Andreas Röhler @ 2011-03-01 11:44 UTC (permalink / raw)
To: help-gnu-emacs
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))))
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: print out all members of a list
[not found] ` <mailman.5.1298979610.15512.help-gnu-emacs@gnu.org>
@ 2011-03-01 13:10 ` Pascal J. Bourguignon
2011-03-01 14:45 ` Stefan Monnier
` (3 more replies)
0 siblings, 4 replies; 29+ messages in thread
From: Pascal J. Bourguignon @ 2011-03-01 13:10 UTC (permalink / raw)
To: help-gnu-emacs
Andreas Röhler <andreas.roehler@easy-emacs.de> 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"
--
__Pascal Bourguignon__ http://www.informatimago.com/
A bad day in () is better than a good day in {}.
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: print out all members of a list
2011-03-01 13:10 ` Pascal J. Bourguignon
@ 2011-03-01 14:45 ` Stefan Monnier
2011-03-01 14:50 ` Le Wang
` (2 subsequent siblings)
3 siblings, 0 replies; 29+ messages in thread
From: Stefan Monnier @ 2011-03-01 14:45 UTC (permalink / raw)
To: help-gnu-emacs
> (insert (format "\n%s" (prin1-to-string elem)))))
You meant
(insert (format "\n%S elem))))
right?
Stefan
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: print out all members of a list
2011-03-01 13:10 ` Pascal J. Bourguignon
2011-03-01 14:45 ` Stefan Monnier
@ 2011-03-01 14:50 ` Le Wang
2011-03-01 15:10 ` Richard Riley
2011-03-01 18:39 ` Andreas Röhler
3 siblings, 0 replies; 29+ messages in thread
From: Le Wang @ 2011-03-01 14:50 UTC (permalink / raw)
To: Pascal J. Bourguignon; +Cc: help-gnu-emacs
[-- Attachment #1: Type: text/plain, Size: 311 bytes --]
prin1-to-string knows how to quote strings properly ... got it.
On Tue, Mar 1, 2011 at 9:10 PM, Pascal J. Bourguignon <pjb@informatimago.com
> wrote:
> Why do you write broken code?
>
...
> Is it not easier to write code that works?
But maybe we don't have to talk like cthun to make our points?
--
Le
[-- Attachment #2: Type: text/html, Size: 805 bytes --]
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: print out all members of a list
2011-03-01 13:10 ` Pascal J. Bourguignon
2011-03-01 14:45 ` Stefan Monnier
2011-03-01 14:50 ` Le Wang
@ 2011-03-01 15:10 ` Richard Riley
2011-03-01 18:39 ` Andreas Röhler
3 siblings, 0 replies; 29+ messages in thread
From: Richard Riley @ 2011-03-01 15:10 UTC (permalink / raw)
To: help-gnu-emacs
"Pascal J. Bourguignon" <pjb@informatimago.com> writes:
> Andreas Röhler <andreas.roehler@easy-emacs.de> 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?
I'm intrigued. Do you get a bonus point for every time you are rude and
condescending to people looking for help or are patiently helping
others?
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: print out all members of a list
2011-03-01 13:10 ` Pascal J. Bourguignon
` (2 preceding siblings ...)
2011-03-01 15:10 ` Richard Riley
@ 2011-03-01 18:39 ` Andreas Röhler
3 siblings, 0 replies; 29+ messages in thread
From: Andreas Röhler @ 2011-03-01 18:39 UTC (permalink / raw)
To: help-gnu-emacs
Am 01.03.2011 14:10, schrieb Pascal J. Bourguignon:
> Andreas Röhler<andreas.roehler@easy-emacs.de> 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)))))
(?) :-)
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: print out all members of a list, v.1.0
2011-03-01 6:02 ` rusi
@ 2011-03-02 4:51 ` Barry Margolin
2011-03-02 5:33 ` rusi
2011-03-02 11:56 ` Pascal J. Bourguignon
0 siblings, 2 replies; 29+ messages in thread
From: Barry Margolin @ 2011-03-02 4:51 UTC (permalink / raw)
To: help-gnu-emacs
In article
<d00d6215-5ab4-499d-8e7b-07168ad8a371@o18g2000prh.googlegroups.com>,
rusi <rustompmody@gmail.com> wrote:
> yes it is. emacs lisp became obsolete when scheme and common lisp came
> out -- which is about 30 years ago.
How is that possible, since Emacs Lisp came out AFTER Scheme and Common
Lisp? CLtL was published in 1984, the same year Stallman started
writing GNU Emacs? And Scheme is older, since CL took a number of ideas
from it (most notably lexical scoping).
--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: print out all members of a list, v.1.0
2011-03-02 4:51 ` Barry Margolin
@ 2011-03-02 5:33 ` rusi
2011-03-02 11:56 ` Pascal J. Bourguignon
1 sibling, 0 replies; 29+ messages in thread
From: rusi @ 2011-03-02 5:33 UTC (permalink / raw)
To: help-gnu-emacs
On Mar 2, 9:51 am, Barry Margolin <bar...@alum.mit.edu> wrote:
> In article
> <d00d6215-5ab4-499d-8e7b-07168ad8a...@o18g2000prh.googlegroups.com>,
>
> rusi <rustompm...@gmail.com> wrote:
> > yes it is. emacs lisp became obsolete when scheme and common lisp came
> > out -- which is about 30 years ago.
>
> How is that possible, since Emacs Lisp came out AFTER Scheme and Common
> Lisp? CLtL was published in 1984, the same year Stallman started
> writing GNU Emacs? And Scheme is older, since CL took a number of ideas
> from it (most notably lexical scoping).
Ok I stand corrected technically.
I was speaking more generically -- elisp as a member of the
dynamically scoped 2-lisp family.
ie. to the family of {MAC,Franz,UCI}-lisps that preceded scheme and
CL.
[Personal note: I did my degree project in mid 80s writing a lisp
interpreter. The only reference I had was the UCI lisp manual. I
thought the scoping (I had implemented) was strange (static/dynamic
etc were no words I knew then). After I finished I got hold of the CL
manual
and then had the 'Aha: ' The goofup was not mine!]
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: print out all members of a list, v.1.0
2011-03-02 4:51 ` Barry Margolin
2011-03-02 5:33 ` rusi
@ 2011-03-02 11:56 ` Pascal J. Bourguignon
2011-03-03 0:36 ` Barry Margolin
1 sibling, 1 reply; 29+ messages in thread
From: Pascal J. Bourguignon @ 2011-03-02 11:56 UTC (permalink / raw)
To: help-gnu-emacs
Barry Margolin <barmar@alum.mit.edu> writes:
> In article
> <d00d6215-5ab4-499d-8e7b-07168ad8a371@o18g2000prh.googlegroups.com>,
> rusi <rustompmody@gmail.com> wrote:
>
>> yes it is. emacs lisp became obsolete when scheme and common lisp came
>> out -- which is about 30 years ago.
>
> How is that possible, since Emacs Lisp came out AFTER Scheme and Common
> Lisp? CLtL was published in 1984, the same year Stallman started
> writing GNU Emacs? And Scheme is older, since CL took a number of ideas
> from it (most notably lexical scoping).
At the same time as CL.
The CL standard was completed in 1994. 1984 only marks the beginning
of the standardization effort.
--
__Pascal Bourguignon__ http://www.informatimago.com/
A bad day in () is better than a good day in {}.
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: print out all members of a list, v.1.0
2011-03-02 11:56 ` Pascal J. Bourguignon
@ 2011-03-03 0:36 ` Barry Margolin
2011-03-03 9:02 ` Pascal J. Bourguignon
0 siblings, 1 reply; 29+ messages in thread
From: Barry Margolin @ 2011-03-03 0:36 UTC (permalink / raw)
To: help-gnu-emacs
In article <87r5apwxad.fsf@kuiper.lan.informatimago.com>,
"Pascal J. Bourguignon" <pjb@informatimago.com> wrote:
> Barry Margolin <barmar@alum.mit.edu> writes:
>
> > In article
> > <d00d6215-5ab4-499d-8e7b-07168ad8a371@o18g2000prh.googlegroups.com>,
> > rusi <rustompmody@gmail.com> wrote:
> >
> >> yes it is. emacs lisp became obsolete when scheme and common lisp came
> >> out -- which is about 30 years ago.
> >
> > How is that possible, since Emacs Lisp came out AFTER Scheme and Common
> > Lisp? CLtL was published in 1984, the same year Stallman started
> > writing GNU Emacs? And Scheme is older, since CL took a number of ideas
> > from it (most notably lexical scoping).
>
> At the same time as CL.
> The CL standard was completed in 1994. 1984 only marks the beginning
> of the standardization effort.
So? CL predates the standardization effort. 1984 marks the END of
several years of work that produced the book "Common Lisp: the Language".
--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: print out all members of a list, v.1.0
2011-03-03 0:36 ` Barry Margolin
@ 2011-03-03 9:02 ` Pascal J. Bourguignon
2011-03-03 15:37 ` rusi
2011-03-04 2:34 ` Barry Margolin
0 siblings, 2 replies; 29+ messages in thread
From: Pascal J. Bourguignon @ 2011-03-03 9:02 UTC (permalink / raw)
To: help-gnu-emacs
Barry Margolin <barmar@alum.mit.edu> writes:
> In article <87r5apwxad.fsf@kuiper.lan.informatimago.com>,
> "Pascal J. Bourguignon" <pjb@informatimago.com> wrote:
>
>> Barry Margolin <barmar@alum.mit.edu> writes:
>>
>> > In article
>> > <d00d6215-5ab4-499d-8e7b-07168ad8a371@o18g2000prh.googlegroups.com>,
>> > rusi <rustompmody@gmail.com> wrote:
>> >
>> >> yes it is. emacs lisp became obsolete when scheme and common lisp came
>> >> out -- which is about 30 years ago.
>> >
>> > How is that possible, since Emacs Lisp came out AFTER Scheme and Common
>> > Lisp? CLtL was published in 1984, the same year Stallman started
>> > writing GNU Emacs? And Scheme is older, since CL took a number of ideas
>> > from it (most notably lexical scoping).
>>
>> At the same time as CL.
>> The CL standard was completed in 1994. 1984 only marks the beginning
>> of the standardization effort.
>
> So? CL predates the standardization effort. 1984 marks the END of
> several years of work that produced the book "Common Lisp: the Language".
Well, I understand reticence of RMS to use a language that's not even
standardized yet. Of course, I shall then wonder why he had to design
his own non-standardized language.
--
__Pascal Bourguignon__ http://www.informatimago.com/
A bad day in () is better than a good day in {}.
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: print out all members of a list, v.1.0
2011-03-03 9:02 ` Pascal J. Bourguignon
@ 2011-03-03 15:37 ` rusi
2011-03-03 16:00 ` Pascal J. Bourguignon
2011-03-04 2:34 ` Barry Margolin
1 sibling, 1 reply; 29+ messages in thread
From: rusi @ 2011-03-03 15:37 UTC (permalink / raw)
To: help-gnu-emacs
On Mar 3, 2:02 pm, "Pascal J. Bourguignon" <p...@informatimago.com>
wrote:
> Well, I understand reticence of RMS to use a language that's not even
> standardized yet. Of course, I shall then wonder why he had to design
> his own non-standardized language.
Reticence??
I guess you mean hesitation/reluctance or some such? If you are
actually saying 'reticence' that's a cute usage given how much rms is
participating in these discussions :-)
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: print out all members of a list, v.1.0
2011-03-03 15:37 ` rusi
@ 2011-03-03 16:00 ` Pascal J. Bourguignon
0 siblings, 0 replies; 29+ messages in thread
From: Pascal J. Bourguignon @ 2011-03-03 16:00 UTC (permalink / raw)
To: help-gnu-emacs
rusi <rustompmody@gmail.com> writes:
> On Mar 3, 2:02 pm, "Pascal J. Bourguignon" <p...@informatimago.com>
> wrote:
>
>> Well, I understand reticence of RMS to use a language that's not even
>> standardized yet. Of course, I shall then wonder why he had to design
>> his own non-standardized language.
>
>
> Reticence??
> I guess you mean hesitation/reluctance or some such? If you are
> actually saying 'reticence' that's a cute usage given how much rms is
> participating in these discussions :-)
Well, I'm not a native, but
http://www.thefreedictionary.com/reticence
ret·i·cence (rt-sns)
n.
1. The state or quality of being reticent; reserve.
2. The state or quality of being reluctant; unwillingness.
3. An instance of being reticent.
I definitely meant the 2. definition.
--
__Pascal Bourguignon__ http://www.informatimago.com/
A bad day in () is better than a good day in {}.
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: print out all members of a list, v.1.0
2011-03-03 9:02 ` Pascal J. Bourguignon
2011-03-03 15:37 ` rusi
@ 2011-03-04 2:34 ` Barry Margolin
2011-03-04 4:09 ` Drew Adams
2011-03-04 10:39 ` Pascal J. Bourguignon
1 sibling, 2 replies; 29+ messages in thread
From: Barry Margolin @ 2011-03-04 2:34 UTC (permalink / raw)
To: help-gnu-emacs
In article <878vwwwp8d.fsf@kuiper.lan.informatimago.com>,
"Pascal J. Bourguignon" <pjb@informatimago.com> wrote:
> Barry Margolin <barmar@alum.mit.edu> writes:
>
> > In article <87r5apwxad.fsf@kuiper.lan.informatimago.com>,
> > "Pascal J. Bourguignon" <pjb@informatimago.com> wrote:
> >
> >> Barry Margolin <barmar@alum.mit.edu> writes:
> >>
> >> > In article
> >> > <d00d6215-5ab4-499d-8e7b-07168ad8a371@o18g2000prh.googlegroups.com>,
> >> > rusi <rustompmody@gmail.com> wrote:
> >> >
> >> >> yes it is. emacs lisp became obsolete when scheme and common lisp came
> >> >> out -- which is about 30 years ago.
> >> >
> >> > How is that possible, since Emacs Lisp came out AFTER Scheme and Common
> >> > Lisp? CLtL was published in 1984, the same year Stallman started
> >> > writing GNU Emacs? And Scheme is older, since CL took a number of ideas
> >> > from it (most notably lexical scoping).
> >>
> >> At the same time as CL.
> >> The CL standard was completed in 1994. 1984 only marks the beginning
> >> of the standardization effort.
> >
> > So? CL predates the standardization effort. 1984 marks the END of
> > several years of work that produced the book "Common Lisp: the Language".
>
> Well, I understand reticence of RMS to use a language that's not even
> standardized yet. Of course, I shall then wonder why he had to design
> his own non-standardized language.
Emacs Lisp is mostly a reimplementation of MockLisp, the dialect that
was used in Gosling Emacs, which was the original inspiration for GNU
Emacs. It's also very much like MACLISP, the dialect that RMS had been
using for over a decade.
So he didn't design his own language, he was basically sticking with
what he knew and liked.
--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***
^ permalink raw reply [flat|nested] 29+ messages in thread
* RE: print out all members of a list, v.1.0
2011-03-04 2:34 ` Barry Margolin
@ 2011-03-04 4:09 ` Drew Adams
2011-03-04 10:39 ` Pascal J. Bourguignon
1 sibling, 0 replies; 29+ messages in thread
From: Drew Adams @ 2011-03-04 4:09 UTC (permalink / raw)
To: 'Barry Margolin', help-gnu-emacs
> Emacs Lisp is mostly a reimplementation of MockLisp, the dialect that
> was used in Gosling Emacs, which was the original inspiration for GNU
> Emacs. It's also very much like MACLISP, the dialect that
> RMS had been using for over a decade.
>
> So he didn't design his own language, he was basically sticking with
> what he knew and liked.
Hm. Not to disagree too much, but on one point in particular: MockLisp was not
in any sense a dialect of Lisp - it was not Lisp at all. It only had some of
the appearance of Lisp (parenthesized expressions), none of the behavior.
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: print out all members of a list, v.1.0
2011-03-04 2:34 ` Barry Margolin
2011-03-04 4:09 ` Drew Adams
@ 2011-03-04 10:39 ` Pascal J. Bourguignon
2011-03-04 11:06 ` David Kastrup
2011-03-05 3:24 ` Barry Margolin
1 sibling, 2 replies; 29+ messages in thread
From: Pascal J. Bourguignon @ 2011-03-04 10:39 UTC (permalink / raw)
To: help-gnu-emacs
Barry Margolin <barmar@alum.mit.edu> writes:
> Emacs Lisp is mostly a reimplementation of MockLisp, the dialect that
> was used in Gosling Emacs, which was the original inspiration for GNU
> Emacs. It's also very much like MACLISP, the dialect that RMS had been
> using for over a decade.
>
> So he didn't design his own language, he was basically sticking with
> what he knew and liked.
MacLisp probably. CL is inspired a lot from MacLisp too. But I've
read that MockLisp was far from being a full lisp (as its name would
imply), and that it was probably the reason why RMS had to write a new
real lisp for his emacs.
--
__Pascal Bourguignon__ http://www.informatimago.com/
A bad day in () is better than a good day in {}.
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: print out all members of a list, v.1.0
2011-03-04 10:39 ` Pascal J. Bourguignon
@ 2011-03-04 11:06 ` David Kastrup
2011-03-05 3:24 ` Barry Margolin
1 sibling, 0 replies; 29+ messages in thread
From: David Kastrup @ 2011-03-04 11:06 UTC (permalink / raw)
To: help-gnu-emacs
"Pascal J. Bourguignon" <pjb@informatimago.com> writes:
> Barry Margolin <barmar@alum.mit.edu> writes:
>> Emacs Lisp is mostly a reimplementation of MockLisp, the dialect that
>> was used in Gosling Emacs, which was the original inspiration for GNU
>> Emacs. It's also very much like MACLISP, the dialect that RMS had
>> been using for over a decade.
>>
>> So he didn't design his own language, he was basically sticking with
>> what he knew and liked.
>
> MacLisp probably. CL is inspired a lot from MacLisp too. But I've
> read that MockLisp was far from being a full lisp (as its name would
> imply), and that it was probably the reason why RMS had to write a new
> real lisp for his emacs.
I suggest you google for a bit of history about Stallman and Gosling
Emacs. Not being able to use Gosling Emacs/MockLisp any more even
though many contributions to it were _intended_ to be made freely
available was actually the reason for Stallman to stop believing in
universal goodness and create the GPL.
--
David Kastrup
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: print out all members of a list, v.1.0
2011-03-04 10:39 ` Pascal J. Bourguignon
2011-03-04 11:06 ` David Kastrup
@ 2011-03-05 3:24 ` Barry Margolin
1 sibling, 0 replies; 29+ messages in thread
From: Barry Margolin @ 2011-03-05 3:24 UTC (permalink / raw)
To: help-gnu-emacs
In article <878vwvuq3o.fsf@kuiper.lan.informatimago.com>,
"Pascal J. Bourguignon" <pjb@informatimago.com> wrote:
> Barry Margolin <barmar@alum.mit.edu> writes:
> > Emacs Lisp is mostly a reimplementation of MockLisp, the dialect that
> > was used in Gosling Emacs, which was the original inspiration for GNU
> > Emacs. It's also very much like MACLISP, the dialect that RMS had been
> > using for over a decade.
> >
> > So he didn't design his own language, he was basically sticking with
> > what he knew and liked.
>
> MacLisp probably. CL is inspired a lot from MacLisp too. But I've
> read that MockLisp was far from being a full lisp (as its name would
> imply), and that it was probably the reason why RMS had to write a new
> real lisp for his emacs.
I think he may have taken much inspiration from Multics Maclisp and the
macros used in Multics Emacs. For example, I think that's where
save-excursion came from. It was also case-sensitive, unlike PDP-10
MACLISP.
I imagine this is the only good thing RMS would admit came out of
Multics. He wasn't a big fan of the OS because security was one of its
central features.
--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***
^ permalink raw reply [flat|nested] 29+ messages in thread
end of thread, other threads:[~2011-03-05 3:24 UTC | newest]
Thread overview: 29+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-02-28 15:20 print out all members of a list ken
2011-02-28 16:50 ` Teemu Likonen
2011-02-28 17:21 ` ken
2011-02-28 18:25 ` print out all members of a list, v.1.0 ken
2011-02-28 18:32 ` print out all members of a list Thierry Volpiatto
2011-02-28 20:26 ` PJ Weisberg
[not found] ` <mailman.5.1298917525.1451.help-gnu-emacs@gnu.org>
2011-02-28 21:32 ` print out all members of a list, v.1.0 Tim X
2011-03-01 5:48 ` Pascal J. Bourguignon
2011-03-01 6:02 ` rusi
2011-03-02 4:51 ` Barry Margolin
2011-03-02 5:33 ` rusi
2011-03-02 11:56 ` Pascal J. Bourguignon
2011-03-03 0:36 ` Barry Margolin
2011-03-03 9:02 ` Pascal J. Bourguignon
2011-03-03 15:37 ` rusi
2011-03-03 16:00 ` Pascal J. Bourguignon
2011-03-04 2:34 ` Barry Margolin
2011-03-04 4:09 ` Drew Adams
2011-03-04 10:39 ` Pascal J. Bourguignon
2011-03-04 11:06 ` David Kastrup
2011-03-05 3:24 ` Barry Margolin
[not found] ` <mailman.0.1298913700.1451.help-gnu-emacs@gnu.org>
2011-03-01 5:41 ` print out all members of a list Pascal J. Bourguignon
2011-03-01 11:33 ` Andreas Röhler
2011-03-01 11:44 ` Andreas Röhler
[not found] ` <mailman.5.1298979610.15512.help-gnu-emacs@gnu.org>
2011-03-01 13:10 ` Pascal J. Bourguignon
2011-03-01 14:45 ` Stefan Monnier
2011-03-01 14:50 ` Le Wang
2011-03-01 15:10 ` Richard Riley
2011-03-01 18:39 ` Andreas Röhler
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.