let sublist =  function
  p -> (let rec g = function
          lx -> if is_empty_list (lx)
                  then empty_list ()
                  else if p (head (lx))
                         then cons_list (head (lx), g (tail (lx)))
                         else g (tail (lx))
        in
          g)