Ad
  • Default User Avatar

    This is not about refactoring, please remove the tag.

  • Default User Avatar

    This is not about refactoring, please remove the tag.

  • Default User Avatar

    This is not about refactoring, please remove the tag.

  • Default User Avatar

    Don't you think it's incorrect to tag it "functional programming"?

    Or don't you think incorrect tagging is an issue?

  • Default User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Default User Avatar

    You could also test yielding null-values, with and without combining with yieldFrom.

    When a generator is done, next() should return null. But if yielding null the generator might not be done.

  • Default User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Default User Avatar

    I think I see what you want to do here. Should using unrelated geneators running simultaneously in parallel threads work?

    I don't this this kata requires that, but it would be nice anyway.

  • Default User Avatar

    This is not functional programming, please remove that tag.

  • Default User Avatar

    It seems like a lot of katas have irrelevant tags to attract users, and no way to deal with it. It ruins my experience when my first task for every kata is to figure out if it's even relevant, and most of the time it isn't.

  • Default User Avatar

    I agree, it's a mess. But you could use your browsers search function. :)

  • Default User Avatar

    I don't see how this is related to any of the following tags: LAMBDAS, FUNCTIONAL PROGRAMMING, FUNCTIONS, DECLARATIVE PROGRAMMING

    I also think DATA STRUCTURES is a bit of a stretch.

    Most of the reference implementations doesn't even use functional programming.

  • Default User Avatar

    I see now that this has been reported before, and was closed without solving the issue. I only checked open issues before reporting.

  • Default User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Default User Avatar

    The test for filterS has false negatives.

    final int start = +rand.nextInt();
    int pos = start % 2;
    for (int i : Stream.fromS(start).filterS(x -> x % 2 == 0).get().takeS(10)) {
        assertTrue("filtering odds with filterS", i % 2 == 0);
        assertTrue("filterS should preserve satisfying elements", start + pos == i);
        pos += 2;
    }
    

    In Java, mod of a negative number gives a negative result (or zero). So if start is -7 then pos is set to -1. Add that to start, and test expects the first number in the stream to be -8. This should of course be -6.

    I suggest int pos = start % 2 == 0 ? 0 : 1; or int pos = Math.abs(start % 2);.