14 lines
334 B
OCaml
14 lines
334 B
OCaml
let rec place e l = match l with
|
|
| [ ] -> [e]
|
|
| x::xs -> if e < x then e::x::xs
|
|
else x :: (place e xs)
|
|
|
|
let rec is_elem e l = match l with
|
|
| [ ] -> false
|
|
| x::xs -> e = x || (e > x && is_elem e xs)
|
|
|
|
let rec sorted l = match l with
|
|
| [ ] -> true
|
|
| x::[] -> true
|
|
| x1::x2::xs -> x1 <= x2 && sorted (x2::xs)
|
|
|