Find all permutations of a string

Recusive solution that uses O(n2) memory. A more memory effienct solution would use global state to flag which letters have been used while deeper in the call stack. I opted for a more functional solution without global state.