Comment

Comment by dblotsky

Does anyone else 100% disagree with the claim that this "lambda version is more concise and expresses its intent effectively"?

  public static List generate(int series) {
      return Stream.iterate(new int[]{0, 1}, s -> new int[]{s[1], s[0] + s[1]})
                   .limit(series)
                   .map(n -> n[0])
                   .collect(toList());
  }
as opposed to this:

  public int fib(int n) {
      int x = 0, y = 1, z = 1;
      for (int i = 0; i < n; i++) {
          x = y;
          y = z;
          z = x + y;
      }
      return x;
  }
parent dblotsky 8 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton