Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question

marked as duplicate by R. M. Jan 28 '13 at 14:33

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

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

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

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


you could extract all the values considering the FullForm:


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

w = v[[All, 2]]

{1.03, 2.01, 3.02}

share|improve this answer
Table[x /. v[[i]], {i, 1, n}] gave all of them too. – daniel Jan 28 '13 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


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

share|improve this answer
achive/.achive->achieve... – einbandi Jan 28 '13 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} *)
share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.