Currently, if users want to achieve
foldr on a String, they have to choose one from the alternatives below as their workaround:
collectthe string and get a char array, and
foldramong this array, causing redundant copy once.
reversed String, causing redundant copy once.
- find the string’s
lastindexand then get reversed indices of strings as a lazy stream, causing no redundant copy but extremely annoying and really tricky(also affect the maintainability).
I wonder if there’s another feasible solution without redundant copy.