Programming Challenges
Let's solve coding challenges to practice compound datatypes.
Challenge 1: Find the longest string in a string list
Write an OCaml function, longest_string: string list -> string option, to find the longest string in a list of strings.
Examples:
longest_string [] = None
longest_string ["a"; "ABC"; "ab"] = Some "abc"
Hint: You can use OCaml’s String.length function to compute the length of a string.
Challenge 2: Concatenate strings
Write an OCaml function, concat: string -> string list -> string, to add a string s and a list of string ...