Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let max_seq lst =
- let rec helper lst bi bc ti tc oh =
- (*print_string "BEST_ITEM ";
- print_int bi; print_string " BEST_CNT ";
- print_int bc; print_string " THIS_ITEM ";
- print_int ti; print_string " THIS_CNT ";
- print_int tc; print_string " OLD_H ";
- print_int oh; print_string "\n";
- *)
- match lst with
- | h :: t ->
- if (h = oh) then (
- if (tc>=bc) then helper t h (tc+1) h (tc+1) h
- else helper t bi bc h (tc+1) h
- )
- else helper t bi bc h 1 h
- | _ -> bi;
- in helper lst 0 0 0 0 6 (* 6 = lst[0] *)
- ;;
- let res = max_seq [6;6;6;2;2;2;2;2;6;6;8;8];;
- print_string "\nMax: ";;
- print_int(res);;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement