# Rearrangement of the list

I have the following list:

m = {{x == 0, y == 0.29264681456942615},
{x == 30, y == 0.2419119568894183},
{x == 50, y == 0.1485164898707659},
{x == 70, y == 0.05437093382683481},
{x == 90 , y == 1.}}

I would like to convert it to the form {{0,0.29264681456942615},{30, 0.2419119568894183}, ... } (extracting only the numbers form the list). How can I do this?

-
m[[;; , ;; , 2]] should do the trick. To see why check the result of the following: Head[a==b], (a==b)[[0]], (a==b)[[1]], (a==b)[[2]] – ssch Nov 6 '12 at 14:32
alternatively m /. Equal[_, b_] -> b – chris Nov 6 '12 at 14:42
That's way neater since it can be used even if the order was {3==x,8==y} in some places, m /. Equal[a_, b_] :> If[NumberQ[a], a, b] – ssch Nov 6 '12 at 14:54
Map[Last, m, {2}]. – J. M. Nov 6 '12 at 14:56
@ssch equivalent but perhaps less cryptic for the novice: m[[All,All,2]] – Yves Klett Nov 6 '12 at 15:05

One of many possible ways is

{x, y} /. (m /. Equal -> Rule)

What happens here: Let's say you want to transform the expression x equals 0 into x is replaced by 0, then you can do exactly this by ReplaceAll (ok, replacing all) Equals in your list into Rules which is done by (m /. Equal -> Rule). The rest is to use it and replace {x,y} with these rules.

One disadvantage of this approach which is shared by following solutions from the comments:

m[[;; , ;; , 2]]
m[[All,All,2]]
m[[All, All, -1]]
m /. Equal[_, b_] -> b
Map[Last, m, {2}]

is that it relies on the fact, that your number is in the end. This can be prevented by using for instance a rule which checks where the numeric value is like suggested by ssch

m /. Equal[a_, b_] :> If[NumberQ[a], a, b]
-
Hmmm... why the RuleDelayed in your first example? Rule works too. +1 for the didactic explanation. – István Zachar Nov 6 '12 at 15:18
@IstvánZachar Thx. No special reason. I use RuleDelayed more often, since in most of my applications I don't want to rhs to be evaluated. But I see, it is maybe confusing the OP here. – halirutan Nov 6 '12 at 15:20
@halirutan the last rule still needs to be delayed (I couldn't edit because 1 character was considered a low quality edit by the system) – ssch Nov 6 '12 at 15:31
@ssch Ah, yes, sorry. I was a bit beside me. – halirutan Nov 6 '12 at 15:37
@ssch To explain why I thought it was not necessary: something like If[boing, a, b] stays unevaluated as long as boing is not True or False. I thought we can use this here and forgot that NumberQ[a] is instantly evaluated to False. Sorry again. – halirutan Nov 6 '12 at 15:40

m = {{x == 0, y == 0.29264681456942615}, {x == 30, y == 0.2419119568894183}, {x == 50, y == 0.1485164898707659}, {x == 70, y == 0.05437093382683481}, {x == 90, y == 1.}};

If lists had this shape I would just

m[[All, All, 2]]

Alternatives are

m /. _ == n_ :> n

or

{x, y} /. (m /. Equal -> Rule)

or even

Block[{Equal = CompoundExpression}, m]

or odd

{x, y} /. First /@ Solve /@ m

all to get

(* {{0, 0.292647}, {30, 0.241912}, {50, 0.148516}, {70, 0.0543709}, {90,
1.}} *)
-
Ok, I just saw that all these except the even and odd ones were already mentioned in comments or answers – Rojo Nov 7 '12 at 0:08
m = {{x == 0, y == 0.29264681456942615}, {x == 30,
y == 0.2419119568894183}, {x == 50,
y == 0.1485164898707659}, {x == 70,
y == 0.05437093382683481}, {x == 90, y == 1.}};

m /. {x == a_, y == b_} -> {a, b}

This returns

{{0, 0.292647}, {30, 0.241912}, {50, 0.148516}, {70, 0.0543709}, {90, 1.}}
-