Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #9417

Re: addRule

From Murta <rodrigomurtax@gmail.com>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: addRule
Date 2012-04-05 09:43 +0000
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Message-ID <jljpgn$cjk$1@smc.vnet.net> (permalink)
References <jlh130$2v$1@smc.vnet.net>

Show all headers | View raw


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

Back to comp.soft-sys.math.mathematica | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

addRule clansa <dauphinester@gmail.com> - 2012-04-04 08:34 +0000
  Re: addRule A Retey <awnl@gmx-topmail.de> - 2012-04-05 09:44 +0000
  Re: addRule Murta <rodrigomurtax@gmail.com> - 2012-04-05 09:43 +0000
  Re: addRule Ray Koopman <koopman@sfu.ca> - 2012-04-05 09:53 +0000
  Re: addRule Yi Wang <tririverwangyi@gmail.com> - 2012-04-05 10:01 +0000

csiph-web