Skip to content

Instantly share code, notes, and snippets.

@edwingustafson
Created October 8, 2018 17:50
Show Gist options
  • Save edwingustafson/9fa20c21048fa07031100a9e574124bb to your computer and use it in GitHub Desktop.
Save edwingustafson/9fa20c21048fa07031100a9e574124bb to your computer and use it in GitHub Desktop.
public List<String> imperative(List<String> terms) {
List<String> result = new ArrayList<String>(terms.size());
for(term : terms) {
if(term.length > 3) {
restult.add(term.toUpperCase());
}
}
return result;
}
public List<String> functional(List<String> terms) {
return terms.stream().
filter(term -> term.length > 3).
map(String::toUpperCase).
toList()
;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment