I'm trying to write a fcn that takes in a list of tuple and an expression (I am working on a postfix expression eval). This function should loop through the expression and find the same letter in the tuple. If it's a match then it returns the int value corresponding to that letter in the tuple. When I ran the code below, my program compiled and run but then it was hanging during execution. What did I do wrong?
let rec getVar ls exp = match ls with |head::tl when (fst head) = exp -> printfn "%d" (snd head) | _ -> getVar ls exp let ls = [("a",5);("b",2);("c",3)] let exp = "ab+" getVar ls exp