Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
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