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

I have a lookup table with about 30 rows. Column 1 has the value I want to search for and column 2 has the value I want returned. It seemed like I should be able to use rules to do this, but clearly I don't know what I'm doing. Oh, the values are all strings

I tried:

rule2 :> (#[[1]] -> #[[2]]) & /@ elrALobMap;

This didn't work. First, should I be doing this a different way? (I see that I can do it with Position and Pick, but that seemed awkward. Second, I'd appreciate any help in understanding how (if it's possible) what I did code should be coded.

share|improve this question
Please provide a few short sample lines of your table. – Yves Klett Oct 31 '13 at 16:00
up vote 3 down vote accepted
elrALobMap = Transpose@{ToString /@ Range@30, ToString /@ Reverse@Range@30}
rules = Dispatch[RuleDelayed @@@ elrALobMap]
"1" /. rules
share|improve this answer
Works great! Thanks. – Mitchell Kaplan Oct 31 '13 at 16:40

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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