Skip to content

Instantly share code, notes, and snippets.

@novoj
Created May 3, 2021 11:13
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 novoj/f02ea9509808a2d3a3912e4bbf2f8cf1 to your computer and use it in GitHub Desktop.
Save novoj/f02ea9509808a2d3a3912e4bbf2f8cf1 to your computer and use it in GitHub Desktop.
String book = "This represents contents of the book.";
final Function<String, IntSupplier> wordCounter = aString ->
() -> aString.split("\\s+").length;
final IntSupplier curry = wordCounter.apply(book);
int countBeforeChange = curry.getAsInt();
book = "Book contents has been changed as of now.";
int countAfterChange = curry.getAsInt();
System.out.print(
countBeforeChange == countAfterChange ? 1 : 0
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment