all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* concat with separators ?
@ 2017-05-24 14:18 Jean-Christophe Helary
  2017-05-24 14:21 ` Kaushal Modi
  0 siblings, 1 reply; 7+ messages in thread
From: Jean-Christophe Helary @ 2017-05-24 14:18 UTC (permalink / raw)
  To: emacs-devel

I just realized today that concat did not come with optional separators (unlike mapconcat). Is there a reason for that ?

Jean-Christophe 


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

* Re: concat with separators ?
  2017-05-24 14:18 concat with separators ? Jean-Christophe Helary
@ 2017-05-24 14:21 ` Kaushal Modi
  2017-05-24 14:34   ` Clément Pit-Claudel
  0 siblings, 1 reply; 7+ messages in thread
From: Kaushal Modi @ 2017-05-24 14:21 UTC (permalink / raw)
  To: Jean-Christophe Helary, emacs-devel

[-- Attachment #1: Type: text/plain, Size: 357 bytes --]

On Wed, May 24, 2017 at 10:19 AM Jean-Christophe Helary <
jean.christophe.helary@gmail.com> wrote:

> I just realized today that concat did not come with optional separators
> (unlike mapconcat). Is there a reason for that ?
>

I just using mapconcat when I feel that need:

Example:

(mapconcat #'identity '("a" "b" "c") "|")  => "a|b|c"
-- 

Kaushal Modi

[-- Attachment #2: Type: text/html, Size: 824 bytes --]

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

* Re: concat with separators ?
  2017-05-24 14:21 ` Kaushal Modi
@ 2017-05-24 14:34   ` Clément Pit-Claudel
  2017-05-28  5:33     ` Jean-Christophe Helary
  0 siblings, 1 reply; 7+ messages in thread
From: Clément Pit-Claudel @ 2017-05-24 14:34 UTC (permalink / raw)
  To: emacs-devel

On 2017-05-24 10:21, Kaushal Modi wrote:
> On Wed, May 24, 2017 at 10:19 AM Jean-Christophe Helary <jean.christophe.helary@gmail.com <mailto:jean.christophe.helary@gmail.com>> wrote:
> 
>     I just realized today that concat did not come with optional separators (unlike mapconcat). Is there a reason for that ?
> 
> 
> I just using mapconcat when I feel that need:
> 
> Example:
> 
> (mapconcat #'identity '("a" "b" "c") "|")  => "a|b|c"

That's roughly the definition of string-join in subr-x:

(defsubst string-join (strings &optional separator)
  "Join all STRINGS using SEPARATOR."
  (mapconcat 'identity strings separator))





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

* Re: concat with separators ?
  2017-05-24 14:34   ` Clément Pit-Claudel
@ 2017-05-28  5:33     ` Jean-Christophe Helary
  2017-05-28 10:52       ` Tino Calancha
  0 siblings, 1 reply; 7+ messages in thread
From: Jean-Christophe Helary @ 2017-05-28  5:33 UTC (permalink / raw)
  To: emacs-devel


> On May 24, 2017, at 23:34, Clément Pit-Claudel <cpitclaudel@gmail.com> wrote:
> 
>> I just realized today that concat did not come with optional separators (unlike mapconcat). Is there a reason for that ?
>> 
>>> I just using mapconcat when I feel that need:
>>> 
>>> Example:
>>> 
>>> (mapconcat #'identity '("a" "b" "c") "|")  => "a|b|c"
>> 
>> That's roughly the definition of string-join in subr-x:
>> 
>> (defsubst string-join (strings &optional separator)
>>  "Join all STRINGS using SEPARATOR."
>>  (mapconcat 'identity strings separator))

Would it be acceptable to provide separators to concat or is it preferable to use string-join instead?

Jean-Christophe 


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

* Re: concat with separators ?
  2017-05-28  5:33     ` Jean-Christophe Helary
@ 2017-05-28 10:52       ` Tino Calancha
  2017-05-28 11:02         ` Jean-Christophe Helary
  0 siblings, 1 reply; 7+ messages in thread
From: Tino Calancha @ 2017-05-28 10:52 UTC (permalink / raw)
  To: Jean-Christophe Helary; +Cc: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 834 bytes --]



On Sun, 28 May 2017, Jean-Christophe Helary wrote:

>
>> On May 24, 2017, at 23:34, Clément Pit-Claudel <cpitclaudel@gmail.com> wrote:
>>
>>> I just realized today that concat did not come with optional separators (unlike mapconcat). Is there a reason for that ?
>>>
>>>> I just using mapconcat when I feel that need:
>>>>
>>>> Example:
>>>>
>>>> (mapconcat #'identity '("a" "b" "c") "|")  => "a|b|c"
>>>
>>> That's roughly the definition of string-join in subr-x:
>>>
>>> (defsubst string-join (strings &optional separator)
>>>  "Join all STRINGS using SEPARATOR."
>>>  (mapconcat 'identity strings separator))
>
> Would it be acceptable to provide separators to concat or is it preferable to use string-join instead?
The latter.
Func. `concat' accepts and arbitrary number of sequences (not a list of
sequences as `string-join').

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

* Re: concat with separators ?
  2017-05-28 10:52       ` Tino Calancha
@ 2017-05-28 11:02         ` Jean-Christophe Helary
  2017-05-28 11:27           ` Tino Calancha
  0 siblings, 1 reply; 7+ messages in thread
From: Jean-Christophe Helary @ 2017-05-28 11:02 UTC (permalink / raw)
  To: emacs-devel


> On May 28, 2017, at 19:52, Tino Calancha <tino.calancha@gmail.com> wrote:
> 
>>>> That's roughly the definition of string-join in subr-x:
>>>> 
>>>> (defsubst string-join (strings &optional separator)
>>>> "Join all STRINGS using SEPARATOR."
>>>> (mapconcat 'identity strings separator))
>> 
>> Would it be acceptable to provide separators to concat or is it preferable to use string-join instead?

> The latter.
> Func. `concat' accepts any arbitrary number of sequences (not a list of
> sequences as `string-join').

I know that, but subr-x is experimental (hence not documented in the manual) and having to use mapconcat just to add a separator seems not practical.

Jean-Christophe 


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

* Re: concat with separators ?
  2017-05-28 11:02         ` Jean-Christophe Helary
@ 2017-05-28 11:27           ` Tino Calancha
  0 siblings, 0 replies; 7+ messages in thread
From: Tino Calancha @ 2017-05-28 11:27 UTC (permalink / raw)
  To: Jean-Christophe Helary; +Cc: emacs-devel



On Sun, 28 May 2017, Jean-Christophe Helary wrote:

>
>> On May 28, 2017, at 19:52, Tino Calancha <tino.calancha@gmail.com> wrote:
>>
>>>>> That's roughly the definition of string-join in subr-x:
>>>>>
>>>>> (defsubst string-join (strings &optional separator)
>>>>> "Join all STRINGS using SEPARATOR."
>>>>> (mapconcat 'identity strings separator))
>>>
>>> Would it be acceptable to provide separators to concat or is it preferable to use string-join instead?
>
>> The latter.
>> Func. `concat' accepts any arbitrary number of sequences (not a list of
>> sequences as `string-join').
>
> I know that, but subr-x is experimental (hence not documented in the manual) and having to use mapconcat just to add a separator seems not practical.
I wouldn't worry too much about `string-join' not being in the manual. 
It's going to keep there.  If it's convenient for you feel free to use it.
Many people here like to use stuff from subr-x.el.

Or you can create in your package a `foo-string-join' (foo being your 
package prefix).  Once you write your package manual, this function will 
be documented in the Emacs manual as well.

We cannot modify `concat' with a new argument `separator' without breaking 
existent code.
You can pass the separator between strings:

(concat "foo" ":" "bar" ":" "qux")
=> "foo:bar:qux"

Or use format:
(format "%s:%s:%s" "foo" "bar" "qux")
=> "foo:bar:qux"




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

end of thread, other threads:[~2017-05-28 11:27 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-05-24 14:18 concat with separators ? Jean-Christophe Helary
2017-05-24 14:21 ` Kaushal Modi
2017-05-24 14:34   ` Clément Pit-Claudel
2017-05-28  5:33     ` Jean-Christophe Helary
2017-05-28 10:52       ` Tino Calancha
2017-05-28 11:02         ` Jean-Christophe Helary
2017-05-28 11:27           ` Tino Calancha

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.