Last active
August 29, 2015 14:09
-
-
Save siosio/d97371dc16f1ec26d865 to your computer and use it in GitHub Desktop.
Revisions
-
siosio renamed this gist
Nov 11, 2014 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
siosio revised this gist
Nov 11, 2014 . 1 changed file with 15 additions and 13 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,6 @@ package gist; import java.io.Serializable; import java.util.Arrays; import java.util.List; import java.util.Random; @@ -9,19 +10,17 @@ import java.util.stream.Stream; public class BonJobi { private static final List<String> INPUT = Arrays.asList("ジョ", "ン", "ボ", "ヴィ"); private static final Random RANDOM = new Random(); public static void main(String[] args) throws Exception { MySupplier supplier = () -> RANDOM.ints(0, INPUT.size()) .limit(2) .mapToObj(INPUT::get) .collect(Collectors.joining()); String result = Stream.iterate(supplier.get(), (s) -> s + '・' + supplier.get()) .filter(s -> s.endsWith("ジョン・ボン・ジョヴィ")) .findFirst() @@ -30,8 +29,11 @@ public class BonJobi { System.out.println(result); System.out.println(result.split("・").length + " Bon Jovis"); System.out.println("\n" + "_人人人人人人人人人人人人人人_\n" + "> You Give Love a Bad Name <\n" + " ̄Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y ̄"); } interface MySupplier extends Supplier<String>, Serializable { } } -
siosio created this gist
Nov 11, 2014 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,37 @@ package gist; import java.util.Arrays; import java.util.List; import java.util.Random; import java.util.function.Supplier; import java.util.stream.Collectors; import java.util.stream.Stream; public class BonJobi { public static void main(String[] args) throws Exception { genBonjovi(); } private int count = 0; private static void genBonjovi() throws Exception { List<String> input = Arrays.asList("ジョ", "ン", "ボ", "ヴィ"); Supplier<String> supplier = () -> new Random().ints(0, input.size()) .limit(2) .mapToObj(input::get) .collect(Collectors.joining()); String result = Stream.iterate(supplier.get(), (s) -> s + '・' + supplier.get()) .filter(s -> s.endsWith("ジョン・ボン・ジョヴィ")) .findFirst() .get(); System.out.println(result); System.out.println(result.split("・").length + " Bon Jovis"); System.out.println("\n" + " _人人人人人人人人人人人人人人_\n" + " > You Give Love a Bad Name <\n" + "  ̄Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y ̄"); } }