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 strings


From: Michael Heerdegen
Subject: Re: Surprising behaviour of 'append' with strings
Date: Sun, 06 Nov 2022 21:33:38 +0100
User-agent: Gnus/5.13 (Gnus v5.13)

"R. Diez" <rdiezmail-emacs@yahoo.de> writes:

> I need a routine like this:
>
> (my-append
>   "1"
>   (list "2" "3")
>   "4"
> )
>
> The result should be:
>  ("1" "2" "3" "4")

(defun my-append (&rest args)
  (cl-mapcan (lambda (x) (if (consp x) x (list x)))
             args))

> As a bonus, 'my-append' should check that all elements are strings, or
> list of strings (no nested lists, and no other data types).

Use `cl-every' on the result of `my-append' with a `stringp' predicate.

Michael.




reply via email to

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