Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (* Write a function is_sorted : string array -> bool which checks if the values of the input array are sorted in strictly increasing order, implying that its elements are unique (use String.compare). *)
- let rec is_sorted (a: string array) : bool =
- let sub_array = Array.sub a 1 (Array.length a - 1) in
- if sub_array = [||]
- then true
- else if String.compare a.(0) sub_array.(0) > 0
- then
- false
- else
- is_sorted sub_array
- ;;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement