Skip to content

Instantly share code, notes, and snippets.

@asaushkin
Created August 2, 2017 13:22
Show Gist options
  • Save asaushkin/2473072ec86111b416b8de7a2a89a413 to your computer and use it in GitHub Desktop.
Save asaushkin/2473072ec86111b416b8de7a2a89a413 to your computer and use it in GitHub Desktop.
Source class for the stream generated from the Alice in Wonderland
import java.util.Arrays;
import java.util.stream.Stream;
public class Alice {
// http://www.alice-in-wonderland.net/resources/chapters-script/alices-adventures-in-wonderland/all-in-the-golden-afternoon/
public static final String POEM = "ALL in the golden afternoon\n" +
"Full leisurely we glide;\n" +
"For both our oars, with little skill,\n" +
"By little arms are plied,\n" +
"While little hands make vain pretence\n" +
"Our wanderings to guide.\n" +
"\n" +
"Ah, cruel Three! In such an hour,\n" +
"Beneath such dreamy weather,\n" +
"To beg a tale of breath too weak\n" +
"To stir the tiniest feather!\n" +
"Yet what can one poor voice avail\n" +
"Against three tongues together?\n" +
"\n" +
"Imperious Prima flashes forth\n" +
"Her edict ‘to begin it’ –\n" +
"In gentler tone Secunda hopes\n" +
"‘There will be nonsense in it!’ –\n" +
"While Tertia interrupts the tale\n" +
"Not more than once a minute.\n" +
"\n" +
"Anon, to sudden silence won,\n" +
"In fancy they pursue\n" +
"The dream-child moving through a land\n" +
"Of wonders wild and new,\n" +
"In friendly chat with bird or beast –\n" +
"And half believe it true.\n" +
"\n" +
"And ever, as the story drained\n" +
"The wells of fancy dry,\n" +
"And faintly strove that weary one\n" +
"To put the subject by,\n" +
"“The rest next time -” “It is next time!”\n" +
"The happy voices cry.\n" +
"\n" +
"Thus grew the tale of Wonderland:\n" +
"Thus slowly, one by one,\n" +
"Its quaint events were hammered out –\n" +
"And now the tale is done,\n" +
"And home we steer, a merry crew,\n" +
"Beneath the setting sun.\n" +
"\n" +
"Alice! a childish story take,\n" +
"And with gentle hand\n" +
"Lay it were Childhood’s dreams are twined\n" +
"In Memory’s mystic band,\n" +
"Like pilgrim’s wither’d wreath of flowers\n" +
"Pluck’d in a far-off land.";
public static final Stream<String> poem() {
return Arrays.asList(POEM.split("\\s")).stream();
}
public static void main(String[] args) {
poem().limit(10).forEach(System.out::println);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment