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

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

Re: Surprising behaviour of 'append' with string


From: Stephen Berman
Subject: Re: Surprising behaviour of 'append' with string
Date: Sun, 06 Nov 2022 18:22:06 +0100
User-agent: Gnus/5.13 (Gnus v5.13)

On Sun, 6 Nov 2022 17:02:48 +0100 "R. Diez" <rdiezmail-emacs@yahoo.de> wrote:

>> then flatten-tree should do the job.  To also check that the elements
>> are either a string or a list of strings, you could use this:
>> [...]
>
> Thanks for your help. Your routine fits the bill perfectly.

Glad it helped.

> Don't you think that 'append' and its documentation are not really
> user friendly? Its behaviour is not what you would normally expect. It
> doesn't make sense to join list elements with the first characters of
> strings.

`append' operates not just on lists but also vectors and strings.  And
with the latter it's not just the first characters that are appended:

(append "this" "is" "a" "test")
=> (116 104 105 115 105 115 97 . "test")
     t   h   i   s   i   s  a

Each element of each sequence -- in this case each character of each
string -- is appended -- except for the last string, which, as the doc
string says "is just used as the tail of the new list".

> At least some example and/or warning about it would prevent unwary
> users like me from wasting time and feeding the general sentiment that
> Emacs and Lisp are not user friendly. I'm only saying this as a hint
> to improve the situation for other users (to improve Emacs). I am now
> fine myself with regards to 'append', thanks to your code.

There are examples in the Emacs Lisp manual.  Perhaps you are familiar
with an append function and string data type in another programming
language and assumed they work the same way in Emacs Lisp.  Consulting
the manual may help further.

Steve Berman



reply via email to

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