Services & Resources / Wolfram Forums / MathGroup Archive

MathGroup Archive 2010

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Overloading StringJoin

  • To: mathgroup at
  • Subject: [mg109819] Re: Overloading StringJoin
  • From: Mark Adler <madler at>
  • Date: Wed, 19 May 2010 07:02:20 -0400 (EDT)
  • References: <hsr8al$bev$> <hstadv$e3i$>

Thank you all for your replies.

On 2010-05-17 23:00:31 -0700, gekko said:
> On May 17, 9:12 pm, Mark Adler <mad... at> wrote:
>> Unprotect[StringJoin];
>> x_List <> y_List := x~Join~y
>> Protect[StringJoin];
> This may work fine for your current needs, but what happens when you
> actually need the StringJoin function?

Well, obviously I wrote so that I can still use <> to join strings. 
This still works:

    "ab" <> "cd"

However as pointed out by Albert Retey, it breaks the flat behavior of
<> where normally this:

    {{"a", "b"}, "c"} <> {"d", {"e", {"f", "g"}}}

produces the single string:


whereas with my violation of StringJoin it returns:

    {{a, b}, c, d, {e, {f, g}}}

That's enough reason for me to not do it, since something else may
depend on that.

Too bad.  <> looks good for a join function and is easy to type.

Chris pointed out the Notation package.  I hadn't noticed that before. 
(I probably haven't noticed about 90% of what Mathematica can do.)  So
now I can do something like:

    << Notation`
    InfixNotation[NotationTemplateTag[**], Join]
    {1, 2} ** {3, 4}
    {1, 2, 3, 4}

I'm sure that there's something wrong with using ** as well, but anyway
you get the idea.  I can make up my own symbol.


  • Prev by Date: Re: Scroll content inside InputField?
  • Next by Date: Re: Handbook of Mathematical functions
  • Previous by thread: Re: Overloading StringJoin
  • Next by thread: Re: Overloading StringJoin