MathGroup Archive 2012

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

Search the Archive

Re: addRule

  • To: mathgroup at smc.vnet.net
  • Subject: [mg125870] Re: addRule
  • From: Christoph Lhotka <christoph.lhotka at fundp.ac.be>
  • Date: Thu, 5 Apr 2012 05:54:05 -0400 (EDT)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • References: <201204040831.EAA29999@smc.vnet.net>

hi,

in your example

data = {{1, {38, 35, 37}}, {2, {21}}, {3, {24, 14}}}

I would use a rule of the form

data /. {j_Integer, k_List} :> Thread[j -> k]

to get

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

best,

christoph



On 04/04/2012 10:31 AM, 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
>




  • References:
    • addRule
      • From: clansa <dauphinester@gmail.com>
  • Prev by Date: Re: addRule
  • Next by Date: Bug in pattern test, or I did something wrong?
  • Previous by thread: Re: addRule
  • Next by thread: Re: addRule