tasks a-s
This commit is contained in:
parent
47bf37c096
commit
b83f433714
12433 changed files with 156208 additions and 123 deletions
|
|
@ -0,0 +1,2 @@
|
|||
# [1;2;1;3;2] < [1;2;0;4;4;0;0;0];;
|
||||
- : bool = false
|
||||
|
|
@ -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
|
||||
|
|
@ -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))
|
||||
|
|
@ -0,0 +1 @@
|
|||
val ordered_lists : 'a list * 'a list -> bool
|
||||
Loading…
Add table
Add a link
Reference in a new issue