Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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

1 Answer 1

up vote 3 down vote accepted
elrALobMap = Transpose@{ToString /@ Range@30, ToString /@ Reverse@Range@30}
rules = Dispatch[RuleDelayed @@@ elrALobMap]
"1" /. rules
(*
30
*)
share|improve this answer
    
Works great! Thanks. –  Mitchell Kaplan Oct 31 '13 at 16:40

Your Answer

 
discard

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.