Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2010

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

Search the Archive

Re: Overloading StringJoin

  • To: mathgroup at smc.vnet.net
  • Subject: [mg109792] Re: Overloading StringJoin
  • From: Albert Retey <awnl at gmx-topmail.de>
  • Date: Tue, 18 May 2010 02:00:59 -0400 (EDT)
  • References: <hsr8al$bev$1@smc.vnet.net>

Am 17.05.2010 13:12, schrieb Mark Adler:
> I use Join enough that I like to overload StringJoin to do it:
> 
> Unprotect[StringJoin];
> x_List <> y_List := x~Join~y
> Protect[StringJoin];
> 
> Then I can do this:
> 
> {1, 2} <> {3, 4}
> {1, 2, 3, 4}
> 
> Why doesn't Mathematica already do this?  

I don't know...

> It seem like an obvious use
> of <>.  Or is there a good reason that they don't do this, and
> therefore if I do, it makes me a bad person?

I think here is a good reason to not do this: What would you expect the
following to return?

{"1", "2"} <> {"3", "4"}

"standard" mathematica evaluates this to a string, your change to
StringJoin changes it to a List, so you might break code that relies on
this behavior...

hth,

albert


  • Prev by Date: Re: Interference data in optica
  • Next by Date: Re: Overloading StringJoin
  • Previous by thread: Re: Overloading StringJoin
  • Next by thread: Re: Overloading StringJoin