MathGroup Archive 1996

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

Search the Archive

Re: ???? How to assign result from Solve to variable ????

  • To: mathgroup at smc.vnet.net
  • Subject: [mg3896] Re: [mg3814] ???? How to assign result from Solve to variable ????
  • From: support (Tom Zeller)
  • Date: Sat, 4 May 1996 23:23:41 -0400
  • Sender: owner-wri-mathgroup at wolfram.com

You can use Part ( [[]] ) or Flatten.  Part gets at the inner list, Flatten
removes the nesting of the list:

In[10]:=
soln = Solve[2x + 6 == 27, x]
Out[10]=
       21
{{x -> --}}
       2
In[11]:=
somevar = x /. soln[[1]]
Out[11]=
21
--
2
In[12]:=
somevar = x /. Flatten[soln]
Out[12]=
21
--
2

Tom Zeller
Wolfram Research Technical Support.


>Hi,
>I was wondering if anyone could tell me how to deal with this problem.
>I want to assign the numerical result that I obtain from the Solve or etc.
>command, which typically enclosed in the braces ({...}) to a variable
>so that I can reuse it. I just want the numerical number, not the braces.
>Can you tell me how? I appreciate all the help from you. Thank you very much.
>
>Ram



==== [MESSAGE SEPARATOR] ====


  • Prev by Date: [Mg3897] Re: Wanted: a trick
  • Next by Date: Re: Re: supplying an arbitrary number of lists to functions
  • Previous by thread: Re: ???? How to assign result from Solve to variable ????
  • Next by thread: Re: ???? How to assign result from Solve to variable ????