Initial data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 72d218235f
commit f23f22d71c
199087 changed files with 3378941 additions and 0 deletions

View file

@ -0,0 +1,2 @@
# [1;2;1;3;2] < [1;2;0;4;4;0;0;0];;
- : bool = false

View file

@ -0,0 +1,2 @@
# [|1;2;1;3;2|] < [|1;2;0;4;4;0;0;0|];;
- : bool = true

View file

@ -0,0 +1,8 @@
let rec ordered_lists = function
| x1::tl1, x2::tl2 ->
(match compare x1 x2 with
| 0 -> ordered_lists (tl1, tl2)
| 1 -> false
| _ -> true)
| [], _ -> true
| _ -> false

View file

@ -0,0 +1,20 @@
(* copy-paste the code of ordered_lists here *)
let make_num_list p n =
let rec aux acc =
if Random.int p = 0 then acc
else aux (Random.int n :: acc)
in
aux []
let print_num_list lst =
List.iter (Printf.printf " %d") lst;
print_newline()
let () =
Random.self_init();
let lst1 = make_num_list 8 5 in
let lst2 = make_num_list 8 5 in
print_num_list lst1;
print_num_list lst2;
Printf.printf "ordered: %B\n" (ordered_lists (lst1, lst2))

View file

@ -0,0 +1 @@
val ordered_lists : 'a list * 'a list -> bool