unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Stephen Berman <stephen.berman@gmx.net>
To: "R. Diez" <rdiezmail-emacs@yahoo.de>
Cc: help-gnu-emacs@gnu.org
Subject: Re: Surprising behaviour of 'append' with string
Date: Sun, 06 Nov 2022 18:22:06 +0100	[thread overview]
Message-ID: <8735aw577l.fsf@gmx.net> (raw)
In-Reply-To: <17b9a480-cff1-212e-7d8a-894285d03646@yahoo.de> (R. Diez's message of "Sun, 6 Nov 2022 17:02:48 +0100")

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	other threads:[~2022-11-06 17:22 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <17b9a480-cff1-212e-7d8a-894285d03646.ref@yahoo.de>
2022-11-06 16:02 ` Surprising behaviour of 'append' with string R. Diez
2022-11-06 17:22   ` Stephen Berman [this message]
2022-11-06 18:41   ` Emanuel Berg
2022-11-07 18:05     ` Michael Heerdegen
2022-11-07 18:35       ` Emanuel Berg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8735aw577l.fsf@gmx.net \
    --to=stephen.berman@gmx.net \
    --cc=help-gnu-emacs@gnu.org \
    --cc=rdiezmail-emacs@yahoo.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).