MathGroup Archive 2002

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

Search the Archive

Re: Using list output (Newbie)

  • To: mathgroup at
  • Subject: [mg37437] Re: Using list output (Newbie)
  • From: Liguo Song < at>
  • Date: Tue, 29 Oct 2002 00:09:40 -0500 (EST)
  • Organization: Department of Physics, Vanderbilt University
  • References: <ZC2v9.44165$>
  • Sender: owner-wri-mathgroup at

Hi, Mitch,

There might be a better way to do this. But, here comes a method used by 
a newbie like me.

Solve will give a list of solutions in form of {{a->1, b->2}, 
{a->2,b->3}}. This is a list, and you can use the normal way to access 
the element of list. Such as A={{a->1, b->2}, {a->2,b->3}}, then A[[1]] 
will give you {a->1, b->2}.
And, A[[1]][[1]] will be a->1.

Here a->1 is Rule[a,1], and you can use A[[1]][[1]][[1]] to get "a", 
while A[[1]][[1]][[2]] to get "1".

Try to read about the Principles of Mathematica in the Mathematica Book 
(in Help Browswer). That will help you to understand all these.

Good luck.

Liguo (Leo)

Mitch Thompson wrote:

>I am trying to reference the output of a Solve command which provided a list
>of 5 solutions (looks like {a->1, b->2, etc.}).
>I would like to extract single answers from this result for use in a
>subsequent calculation.  Any help is appreciated.  Thanks.

  • Prev by Date: Vector field with ImplicitPlot ?
  • Next by Date: Re: random derangement
  • Previous by thread: Bending line
  • Next by thread: Combination/Permutation questions