tailsString function

List<String> tailsString(
  1. String s
)

Returns a list of lists by removing one character at a time.

Implementation

List<String> tailsString(String s) {
  List<int> codes = List.from(s.codeUnits);
  List<String> result = [];
  for (int i = 0; i < s.length; i++) {
    result.add(String.fromCharCodes(codes));
    codes.removeAt(0);
  }
  return result + [''];
}