The goal of this mini-project is to program with strings in OCaml.
Based on Exercise 10 in Week 04, implement an OCaml function of type string -> string -> string that concatenates two strings, using String.init (or Stringy.init if your OCaml installation is version-challenged).
Implement two OCaml functions of type string -> string that reverse a string,
For example, these functions should map "abc" to "cba" and vice versa.
For the purpose of this question, the reverse function of Question 2 is referred to as string_reverse.
For any strings denoted by s1 and s2, what is the relation between string_reverse s1, string_reverse s2, and s1 ^ s2?
Implement a unit-test function for string_reverse that puts this relation to the test.
A palindrome is a string such that enumerating its characters from left to right and from right to left give the same enumeration. So for example, “aba” and “abba” are palindromes, but “abc” isn’t.
Implement a few palindrome generators of type string -> string, i.e., OCaml functions that map a string (which is not necessarily a palindrome) to a palindrome that contains this string. There is no need for unit tests here, your implementations can just be illustrated with a couple of examples. Each of them, however, should be motivated.
A palindrome detector is a function of type string -> bool, i.e., a predicate, such that applying it to a palindrome yields true whereas applying it to a string that is not a palindrome yields false.
Implement an OCaml function that reverses a palindrome.
Implement an OCaml function of type string -> string that, given a string containing the successive characters c0, c1, c2, etc., constructs a string that contains the following successive characters:
For any given string, characterize the length of the resulting string.