Fw: Re: Set of strings reducing problem

• To: mathgroup at smc.vnet.net
• Subject: [mg58657] Fw: [mg58595] Re: Set of strings reducing problem
• From: "Edson Ferreira" <edsferr at uol.com.br>
• Date: Tue, 12 Jul 2005 05:21:40 -0400 (EDT)
• Sender: owner-wri-mathgroup at wolfram.com

```----- Original Message -----
From: "Edson Ferreira" <edsferr at uol.com.br>
To: mathgroup at smc.vnet.net
Subject: [mg58657] Re: [mg58595] Re: Set of strings reducing problem

> Hello!
>
> I've tried this:
>
> In[21]:=
> L={"111","11X","112","1X1","1XX","1X2","121","12X","122"}
> Out[21]=
> {111,11X,112,1X1,1XX,1X2,121,12X,122}
> In[22]:=
> cl=Characters/@L;
> In[23]:=
> r = Dispatch[{"1" + "X" -> "D", "1" + "2" -> "M", "1" + "U" -> "T",
> "X" + "2" -> "U", "X" + "M" -> "T", "2" + "D" -> "T" }];
> In[24]:=
> ncl =StringJoin @@@ ( cl //. {
> x___List,
> {a___, p_String, c___},
> {a___, q_String, c___},
> y___List } :>
> { x, {a, p+q/.r,c}, y } /;
> StringQ[(p+q)/.r])
> Out[24]=
> {111,11X,112,1X1,1XX,1X2,121,12X,122}
>
>
> As you can see, it didn't reduce my set of strings...
>
> Any clue?
>
> Thanks!!
>
> Edson
>
> P.S.: What are those symbols at your code: !!ll and <<ll ??
> Does your code run on Mathematica 5.1?
>
>
> ----- Original Message -----
> From: <rolf at mertig.com>
To: mathgroup at smc.vnet.net
> Sent: Saturday, July 09, 2005 5:07 AM
> Subject: [mg58657] [mg58595] Re: Set of strings reducing problem
>
>
>> Hi,
>> one possibility is to use simple pattern matching:
>>
>>
>> Mathematica 5.2 for Linux x86 (64 bit)
>> Copyright 1988-2005 Wolfram Research, Inc.
>> -- Motif graphics initialized --
>>
>> In[1]:= !!ll
>> L={"11111111",
>>   "11112111",
>>   "1111X111",
>>   "21122211"};
>> cl=Characters/@L;
>>
>> r = Dispatch[{"1" + "X" -> "D", "1" + "2" -> "M", "1" + "U" -> "T",
>> "X" + "2" -> "U", "X" + "M" -> "T", "2" + "D" -> "T" }];
>>
>> ncl =StringJoin @@@ ( cl //. {
>> x___List,
>> {a___, p_String, c___},
>> {a___, q_String, c___},
>> y___List } :>
>> { x, {a, p+q/.r,c}, y } /;
>> StringQ[(p+q)/.r])
>>
>>
>> In[1]:= <<ll
>>
>> Out[1]= {1111T111, 21122211}
>>
>> --
>> Regards,
>>
>> Rolf Mertig
>> GluonVision GmbH
>> Berlin
>>
>>

```

• Prev by Date: Re: //N bug, but WHY?
• Next by Date: Re: //N bug, but WHY?
• Previous by thread: Re:Re: Set of strings reducing problem
• Next by thread: Fw: Re: Set of strings reducing problem