let which i l = let rec continue n = function [] -> assert false | j::l -> if i = j then n else continue (n + 1) l in continue 0 l