1

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.

Dr. belisarius
  • 115,881
  • 13
  • 203
  • 453
Mitchell Kaplan
  • 3,696
  • 22
  • 34

1 Answers1

3
elrALobMap = Transpose@{ToString /@ Range@30, ToString /@ Reverse@Range@30}
rules = Dispatch[RuleDelayed @@@ elrALobMap]
"1" /. rules
(*
30
*)
Dr. belisarius
  • 115,881
  • 13
  • 203
  • 453