Skip to content

Instantly share code, notes, and snippets.

@MrChebik
Last active August 27, 2017 11:05
Show Gist options
  • Save MrChebik/b9d79180b6a682ea34b6788808e4c766 to your computer and use it in GitHub Desktop.
Save MrChebik/b9d79180b6a682ea34b6788808e4c766 to your computer and use it in GitHub Desktop.
public static void main(String[] args) {
final int[] pinger = {0};
System.out.println("WELL, PRINCE, so Genoa and Lucca are now just family estates of the Buonapartes. But I warn you, if you don't tell me that this means war, if you still try to defend the infamies and horrors perpetrated by that Antichrist I really believe he is Antichrist I will have nothing more to do with you and you are no longer my friend, no longer my 'faithful slave', as you call yourself! But how do you do? I see I have frightened you sit down and tell me all the news."
.trim().chars().mapToObj(i -> (char) i).reduce(
new ArrayList<String>(Collections.singletonList("")),
(array, ch) -> {
if (Character.isWhitespace(ch)) {
pinger[0] = 1;
} else {
if (pinger[0] == 1) {
array.add("");
pinger[0] = 0;
}
array.set(array.size() - 1, array.get(array.size() - 1) + ch);
}
return array;
},
(left, right) -> { left.addAll(right); return left; }));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment