# Removing -> from list of numbers [duplicate]

Possible Duplicate:
Best way to extract values from a list of rules?

If I have a vector v = {x->1.03, x-> 2.01, .... }, and I want to use an element in the list, I can get an element as v[[1]] = x-> 1.03 but suppose I want to get rid of the arrow?

Thanks for any suggestions.

-
x /. v[[1]] ? –  cormullion Jan 28 at 11:15
Thanks if you post it as an answer I will upvote and accept. –  daniel Jan 28 at 11:16
there's no hurry :) - the longer you wait, the better the answers become! –  cormullion Jan 28 at 11:17
@rm -rf oy, good catch ;-) –  Yves Klett Jan 28 at 15:27

## marked as duplicate by rm -rf♦Jan 28 at 14:33

Since ReplaceAll (/.) will only return the first match, i.e.

v = {x -> 1.03, x -> 2.01, x -> 3.02};
w = x /. v


1.03

you could extract all the values considering the FullForm:

FullForm[v]


List[Rule[x, 1.03], Rule[x, 2.01], Rule[x,3.02]]

w = v[[All, 2]]


{1.03, 2.01, 3.02}

-
Table[x /. v[[i]], {i, 1, n}] gave all of them too. –  daniel Jan 28 at 13:22

I reckon that by "get rid of the arrow" you mean you want to access only the numbers from v. You can achieve that by using

x/.v[[1]]


This applies the first replacement rule given in v to x. You might want to check out Rule and ReplaceAll in the documentation.

-
achive/.achive->achieve... –  einbandi Jan 28 at 11:21

Not really surprising, but educational: The syntax looks confusing to beginners, but it is very well worth your time to get acquainted with animals like Replace(/.), Rule(->) or Map(/@).

x /. # & /@ {x -> 10, x -> 40}

(*{10, 40} *)


This also works a bit more literally (if not efficently) following your request:

{x -> 10, x -> 40} /. (x -> y_) -> y

(* {10, 40} *)
`
-