(* val long : 'a list -> ('a * int)option * int
long xs returns (opt, n), where
if xs = [], then opt = None;
if xs <> [], then opt = Some(List.hd xs, m), where
m is the length of the longest strictly ascending prefix
of xs;
n is largest such that there is a strictly ascending sublist of
xs with length n *)
let rec long xs =
match xs with
[] -> (None, 0)
| x :: xs ->
match long xs with
(None, n) -> (Some(x, 1), 1) (* n = 0 *)
| (Some(y, m), n) -> (* n >= 1 *)
if x < y
then (Some(x, m + 1),
if n > m + 1 then n else m + 1)
else (Some(x, 1), n)
let longest xs = snd(long xs)