all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* strange behavior of mapconcat
@ 2024-04-15 15:43 shortcutz
  2024-04-15 15:57 ` shortcutz
  2024-04-16  6:36 ` Joost Kremers
  0 siblings, 2 replies; 4+ messages in thread
From: shortcutz @ 2024-04-15 15:43 UTC (permalink / raw)
  To: help-gnu-emacs

Hi all,

In a piece of code I call mapconcat with these arguments:

(mapconcat 'org-no-properties "t" " ")

I'm getting the error (wrong-type-argument sequencep 115). This is the same
if I use the identity function or any other string instead of "t":

(mapconcat 'identity "t" " ")
(mapconcat 'identity "string1 string2" " ")

What am I doing wrong? I don't really understand where the 115 is coming
from. The code is unchanged after macroexpanding, and sequencep says
"string1 string2" and "t" are both valid sequences.

Thanks
R


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: strange behavior of mapconcat
  2024-04-15 15:43 strange behavior of mapconcat shortcutz
@ 2024-04-15 15:57 ` shortcutz
  2024-04-16  6:16   ` Michael Heerdegen via Users list for the GNU Emacs text editor
  2024-04-16  6:36 ` Joost Kremers
  1 sibling, 1 reply; 4+ messages in thread
From: shortcutz @ 2024-04-15 15:57 UTC (permalink / raw)
  To: help-gnu-emacs

Oh, sorry my first post is spam....
it is impossible to concatenate two characters! >_<

On Mon, Apr 15, 2024 at 10:43 AM shortcutz <spookygostee@gmail.com> wrote:

> Hi all,
>
> In a piece of code I call mapconcat with these arguments:
>
> (mapconcat 'org-no-properties "t" " ")
>
> I'm getting the error (wrong-type-argument sequencep 115). This is the
> same if I use the identity function or any other string instead of "t":
>
> (mapconcat 'identity "t" " ")
> (mapconcat 'identity "string1 string2" " ")
>
> What am I doing wrong? I don't really understand where the 115 is coming
> from. The code is unchanged after macroexpanding, and sequencep says
> "string1 string2" and "t" are both valid sequences.
>
> Thanks
> R
>


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: strange behavior of mapconcat
  2024-04-15 15:57 ` shortcutz
@ 2024-04-16  6:16   ` Michael Heerdegen via Users list for the GNU Emacs text editor
  0 siblings, 0 replies; 4+ messages in thread
From: Michael Heerdegen via Users list for the GNU Emacs text editor @ 2024-04-16  6:16 UTC (permalink / raw)
  To: help-gnu-emacs

shortcutz <spookygostee@gmail.com> writes:

> Oh, sorry my first post is spam....
> it is impossible to concatenate two characters! >_<

The FUNCTION argument must return "[...] a sequence of characters" (see
docstring) , so

 (mapconcat #'string "t" " ") ==> "t"

No concatenation involved at all in this example.


Michael.




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: strange behavior of mapconcat
  2024-04-15 15:43 strange behavior of mapconcat shortcutz
  2024-04-15 15:57 ` shortcutz
@ 2024-04-16  6:36 ` Joost Kremers
  1 sibling, 0 replies; 4+ messages in thread
From: Joost Kremers @ 2024-04-16  6:36 UTC (permalink / raw)
  To: shortcutz; +Cc: help-gnu-emacs

On Mon, Apr 15 2024, shortcutz wrote:
> In a piece of code I call mapconcat with these arguments:
>
> (mapconcat 'org-no-properties "t" " ")
>
> I'm getting the error (wrong-type-argument sequencep 115). This is the same
> if I use the identity function or any other string instead of "t":
>
> (mapconcat 'identity "t" " ")
> (mapconcat 'identity "string1 string2" " ")
>
> What am I doing wrong? I don't really understand where the 115 is coming
> from. The code is unchanged after macroexpanding, and sequencep says
> "string1 string2" and "t" are both valid sequences.

They are sequences, but sequences of char (which in Emacs is basically just an
int). What's happening is that the function `org-no-properties` is called on
each element of your string, i.e., on each character, separately. But
`org-no-properties` requires a string as argument, not an int. That's where the
error message is coming from: org-no-properties is saying that it requires a
sequence as argument, but it got the integer 115 (the ASCII value of the
character `t`) instead.

-- 
Joost Kremers
Life has its moments



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-04-16  6:36 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-15 15:43 strange behavior of mapconcat shortcutz
2024-04-15 15:57 ` shortcutz
2024-04-16  6:16   ` Michael Heerdegen via Users list for the GNU Emacs text editor
2024-04-16  6:36 ` Joost Kremers

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.