Skip to content

Instantly share code, notes, and snippets.

@jmaciasluque
Created August 15, 2015 12:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jmaciasluque/5b05479c2fbedbe1ec66 to your computer and use it in GitHub Desktop.
Save jmaciasluque/5b05479c2fbedbe1ec66 to your computer and use it in GitHub Desktop.
static List<String> processWords(List<String> wordList, boolean parallel) {
Supplier<Stream<String>> streamSupplier = parallel ? wordList::parallelStream : wordList::stream;
return
streamSupplier.get()
.sorted()
.map(String::toLowerCase)
.map(String::toUpperCase)
.filter(word -> !word.startsWith("a"))
.filter(word -> !word.startsWith("A"))
.filter(word -> !word.startsWith("z"))
.filter(word -> !word.startsWith("Z"))
.filter(word -> !word.startsWith("m"))
.filter(word -> !word.startsWith("M"))
.distinct()
.collect(Collectors.toList());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment