Re: addRule
- To: mathgroup at smc.vnet.net
- Subject: [mg125872] Re: addRule
- From: Yi Wang <tririverwangyi at gmail.com>
- Date: Thu, 5 Apr 2012 05:54:47 -0400 (EDT)
- Delivered-to: l-mathgroup@mail-archive0.wolfram.com
- References: <jlh130$2v$1@smc.vnet.net>
Hi, Andrew,
You may try
subMap[sub_] := Map[(sub[[1]] -> #) &, sub[[2]] ];
Map[subMap, {{1, {38, 35, 37}}, {2, {21}}, {3, {24, 14}}}]
(* gives {{1 -> 38, 1 -> 35, 1 -> 37}, {2 -> 21}, {3 -> 24, 3 -> 14}} *)
Best,
Yi
On Wednesday, April 4, 2012 4:34:40 AM UTC-4, clansa 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