CSE 130 Fall 2011 - In-Class Exercise 2



Write an Ocaml function

val assoc : 'a * 'b * ('b * 'a) list -> 'a 

that takes a triple (v, k, [(k1,v1);...;(kn,vn)]) and finds the first ki that equals k. If such a ki is found, then the function should return vi, otherwise, the default value v is returned.