Lookup (Right)
Implement the function
val lookup : ('a * 'b) list -> 'a -> 'b option
so that lookup l a is
Some bif there is a pair of the form(a, b)inl. If there are multiple such pairs, the output should be the value associated with the rightmost such pair inl;Noneif there is no such pair.
Examples
let _ = assert (lookup [] 2 = None) let _ = assert (lookup [(2, "2")] 2 = Some "2") let _ = assert (lookup [(2, "2"); (3, "3"); (2, "4"); (3, "5")] 2 = Some "4") let _ = assert (lookup [(2, "2"); (3, "3"); (2, "4"); (3, "5")] 4 = None)