Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2012

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

Search the Archive

Re: addRule

  • To: mathgroup at smc.vnet.net
  • Subject: [mg125838] Re: addRule
  • From: Murta <rodrigomurtax at gmail.com>
  • Date: Thu, 5 Apr 2012 05:42:56 -0400 (EDT)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • References: <jlh130$2v$1@smc.vnet.net>

On Apr 4, 5:34 am, clansa <dauphines... 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

Hi Andrew!

  There is one suggestion
     l = {{1, {38, 35, 37}}, {2, {21}}, {3, {24, 14}}};
     Rule @@@ Distribute[#, List] & /@ l

    {{1 -> 38, 1 -> 35, 1 -> 37}, {2 -> 21}, {3 -> 24, 3 -> 14}}

Best Regards
Murta



  • Prev by Date: Re: How to get the corresponding coefficients?
  • Next by Date: Re: addRule
  • Previous by thread: Re: addRule
  • Next by thread: Re: addRule