MathGroup Archive 2002

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

Search the Archive

Re: Rule application issue

  • To: mathgroup at smc.vnet.net
  • Subject: [mg34152] Re: Rule application issue
  • From: "Allan Hayes" <hay at haystack.demon.co.uk>
  • Date: Tue, 7 May 2002 03:53:45 -0400 (EDT)
  • References: <ab5i1o$jja$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Jari,
Replace -> in

    allDataCollected/.{{NE__}, {NS__},{A___}} ->
        Distribute[{{NE}, {NS}}, List, List,  List, ({{#1[[1]], #2[[1]]},
#1[[2]] #2[[2]]})&]

with :> to get

    allDataCollected/.{{NE__},{NS__},{A___}} :>
        Distribute[{{NE}, {NS}}, List, List,  List, ({{#1[[1]], #2[[1]]},
#1[[2]] #2[[2]]})&]

With ->, Distribute is evaluated before the rule is used, at this time NE
and NS are just symbols - hence the messages that you get. The rule used is
then

    {NS__},{A___}} -> {{{NE[[1]], NS[[1]]}, NE[[2]] NS[[2]]}}

--
Allan

---------------------
Allan Hayes
Mathematica Training and Consulting
Leicester UK
www.haystack.demon.co.uk
hay at haystack.demon.co.uk
Voice: +44 (0)116 271 4198
Fax: +44 (0)870 164 0565


"Jari" <jabidof at yahoo.fr> wrote in message news:ab5i1o$jja$1 at smc.vnet.net...
> Dear Mathgroup,
>
> Consider the following list:
>
> In[353]:=
> allDataCollected={{{2,b+w},{6,d+t}},{{5,f},{4,g},{7,l}},{{{2,1},a},{{4,5},
>           h},{{6,5},j},{{5,4},k},{{8,1},m}}};
>
> Here is the result I want:
>
> In[354]:=
> Distribute[{allDataCollected[[1]],
>     allDataCollected[[2]]}, List, List, List, ({{#1[[1]], #2[[1]]},
> #1[[2]] \
> #2[[2]]})&]
>
> Out[354]=
> {{{2,5},f (b+w)},{{2,4},g (b+w)},{{2,7},l (b+w)},{{6,5},f
> (d+t)},{{6,4},
>     g (d+t)},{{6,7},l (d+t)}}
>
> The problem occurs when I try to obtain the same result but using
> rules (which is mandatory for my application):
>
> In[355]:=
> allDataCollected/.{{NE__},{NS__},{A___}}\[Rule]
>     Distribute[{{NE}, {NS}}, List, List,
>       List, ({{#1[[1]], #2[[1]]}, #1[[2]] #2[[2]]})&]
>
> I get part specifications errors :-(
>
> Anybody's got an idea?
>
> Thanks for your help,
> Jari
>




  • Prev by Date: Re: Some questions about plotting.
  • Next by Date: Re: solve - integer solution
  • Previous by thread: Rule application issue
  • Next by thread: package documentation