let rec lexical_compare list1 list2 = match list1, list2 with
    | [], [] -> 0
    | [], _  -> -1
    | _, []  -> 1
    | (x::xs), (y::ys) -> if x < y then -1 else if x > y then 1 else lexical_compare xs ys