`map-based memoized` in Java8?
问题 In my previous Question here Infinite Fibonacci Sequence with Memoized in Java 8 I asked how to write a code to define the infinite sequence of fibonacci in concise math manner with memoization with Java8 Stream. Thankfully, I've got an answer, and the code below seems to work well: LongStream fibs = Stream .iterate( new long[]{1, 1}, f -> new long[]{f[1], f[0] + f[1]} ) .mapToLong(f -> f[0]); fibs .limit(30) .forEach(System.out::println); 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597