Re: addRule
- To: mathgroup at smc.vnet.net
- Subject: [mg125868] Re: addRule
- From: Barrie Stokes <Barrie.Stokes at newcastle.edu.au>
- Date: Thu, 5 Apr 2012 05:53:23 -0400 (EDT)
- Delivered-to: l-mathgroup@mail-archive0.wolfram.com
- References: <201204040831.EAA29999@smc.vnet.net>
Hello Andrew
My solution is
data = {{1, {38, 35, 37}}, {2, {21}}, {3, {24, 14}}};
Map[ (t \[Function] Map[ (s \[Function] \!\(\*SubscriptBox[\(t\), \(\(\[LeftDoubleBracket]\)\(\ \)\(1\)\(\ \)\
\(\[RightDoubleBracket]\)\)]\) -> s), \!\(\*SubscriptBox[\(t\), \(\(\[LeftDoubleBracket]\)\(\ \)\(2\)\(\ \)\
\(\[RightDoubleBracket]\)\)]\) ]), data ]
(I know it looks horrible in an email, but it looks fine when pasted into Mathematica.)
Dare I suggest you'll get some more concise code suggested, but if you know how Map works, I think this is transparent.
I use the
Map[ (t \[Function] f[t]), data ]
construction as often as possible. In my code the f[t] is another use of the same construction.
Cheers
Barrie
>>> On 04/04/2012 at 6:31 pm, in message <201204040831.EAA29999 at smc.vnet.net>,
clansa <dauphinester at gmail.com> wrote:
> Hello,
> I have these data
> {{1, {38, 35, 37}}, {2, {21}}, {3, {24, 14}}}
> and I want
> {[1->38,1->35,1->37},{2->21},{3->24,3->14}}
> The solution is simple when list of data have the same length
> But what is the solution for my example
> Thanks
>
> Andrew
- References:
- addRule
- From: clansa <dauphinester@gmail.com>
- addRule