filterString function

String filterString(
  1. bool filterFunction(
    1. String sub
    ),
  2. String original
)

Only keep characters that meet criteria

Implementation

String filterString(bool Function(String sub) filterFunction, String original) {
  if (original.isEmpty) {
    return '';
  }
  List<String> copy = letters(original, true);
  for (String letter in listNub(letters(original, true))) {
    if (!filterFunction(letter)) {
      copy.removeWhere((element) => element == letter);
    }
  }

  return concatStrings(copy);
}