Last active
August 29, 2015 14:00
-
-
Save Strikeskids/11463140 to your computer and use it in GitHub Desktop.
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 characters
final Scanner in = new Scanner(System.in); | |
System.out.println("Enter initial value of i: "); | |
while(!in.hasNextInt()){ | |
in.next(); | |
} | |
int i = in.nextInt(); | |
in.close(); | |
int len = State.values().length; | |
IntStream stream = IntStream.iterate(i, (i) -> State.values()[(i%len + len)%len].update(i)); | |
while ((i = stream.nextInt()) >= 0) { | |
System.out.printf("i: %d%n", i); | |
} | |
System.out.printf("Final value is: %d", i); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment