You have most of what you need for doing a reverse.
The basic idea of recursion is to break a task into many smaller steps that are identical. For instance, if you want to compute a factorial (5! = 5*4*3*2*1), one way to do it is to say n! = n*(n-1)!, and note that 0!=1.
For reversing your string, just note that MyString.rev() = MyString.tail().rev()+MyString.head(), and a single character string is its own reverse.
Once you have part 1 done, part 2 is trivial. For testing the prefix, just test the heads and tails of the strings.
|