Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (* 1. Write a function find : string array -> string -> int option such that find a w = Some idx if a.(idx) = w and find a w = None if there is no such index. *)
- let find (str_arr : string array) (str : string) : int option =
- let start = 0 in
- let rec found (index: int) (arr: string array) : int option =
- if index < Array.length(arr)
- then
- if str = arr.(index)
- then Some index
- else found (index + 1) arr
- else None
- in
- found start str_arr
- ;;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement