# Excel lookup function? [duplicate]

This question already has an answer here:

I have two lists, one for the length of words and another list for the corresponding bonus points.

play = {"a", "aa", "caa", "ccbaa", "ccxxxcaa", "ccccaa", "cccccaa",   "ccccccaa", "sdf"}
len = StringLength[play]
{1, 2, 3, 5, 8, 6, 7, 8, 4}
bonusPoints = {0, 10, 20, 30, 40, 50, 60, 75, 85, 95, 100}
(* Excel-like lookup function [len, bonusPoints] *)
(* 0, 10, 20, 40, 75, 50, 60, 75, 30 *)


I have tried with Thread and Lookup but get various errors ("different lengths", etc.). Funny that there is no other question about Excel lookup look alike, it is such a marvellous function. Thank you for your time!

## marked as duplicate by user9660, RunnyKine, MarcoB, m_goldberg, C. E.Mar 24 '16 at 17:21

• bonusPoints[[len]] ? ( If your expected result is correct maybe it needs more explination ) – george2079 Mar 23 '16 at 21:18
• Well, the line Excel like lookup function will somehow take len and bonusPoints as parameters. That is what I mean. Or have I misunderstood your comments? – JSP Mar 23 '16 at 21:21
• In addition to what @george2079 said, in more general case that you might encounter non-integers, maybe even Interpolation[bonusPoints]? Then, simply Map[Interpolation[bonusPoints], len] – MathX Mar 23 '16 at 21:22
• I am sorry, I have corrected the desired output. There are no numbers in between, only integers. – JSP Mar 23 '16 at 21:42
• Could you please elaborate what you want the answer to be? As @george2079 said bonusPoints[[len]]  does return what you want which is {0, 10, 20, 40, 75, 50, 60, 75, 20}. What is wrong with that? Since you edited you changed the length of the last string so I guess you want the answer's last element to be 20? – MathX Mar 23 '16 at 21:59

bonusPoints = {0, 10, 20, 30, 40, 50, 60, 75, 85, 95, 100};

{0, 10, 20, 40, 75, 50, 60, 75, 30}