MathGroup Archive 2000

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

Search the Archive

Re: Making Big Substitution List

  • To: mathgroup at smc.vnet.net
  • Subject: [mg25618] Re: [mg25597] Making Big Substitution List
  • From: BobHanlon at aol.com
  • Date: Mon, 16 Oct 2000 03:04:40 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

In a message dated 10/11/2000 4:24:37 AM, alex000 at my-deja.com writes:

>I have the following list
>P={p1,p2,p3}
>and I would like to create substitution list
>SubsP={p1->1,p2->2,p3->3}
>to use for the future
>
>How do I do it in one nice expression.
>Unfortunately P->{1,2,3} does not
>do the job.
>I am think about somthing like
>Apply[] function but I am lost ...
>

P = {p1, p2, p3};

SubsP = Thread[P -> Range[3]]

{p1 -> 1, p2 -> 2, p3 -> 3}

or

SubsP = Inner[Rule, P, Range[3], List]

{p1 -> 1, p2 -> 2, p3 -> 3}

or

SubsP = Rule[#[[1]], #[[2]]] & /@ Transpose[{P, Range[3]}]

{p1 -> 1, p2 -> 2, p3 -> 3}


Bob Hanlon


  • Prev by Date: help on equation
  • Next by Date: solve(2 A + 2 B +D )*sin(theta)=0
  • Previous by thread: Making Big Substitution List
  • Next by thread: Re: Making Big Substitution List