Ad
  • Default User Avatar

    what method slice doing here?

  • Default User Avatar

    Resolved.

  • Custom User Avatar

    Fixed with your suggestion, thanks :)

  • Custom User Avatar

    It would help if the tests have descriptive names. Something like "ShouldReturnOriginalTo2Places" would help indicated that they need to round (if they forgot it was in the spec).

    Also, the example in the description should have the 2 places ("...the function should return an original price of $100.00")

  • Custom User Avatar

    Create a find fuction that we passed a array and a string. If the string is in the array return true.

    Mispellings and grammer errors. Suggest:

    Create a find function that takes a string and an array. If the string is in the array, return true.

  • Custom User Avatar

    Yes, the tests do not explicitly check for this, so will randomly fail but mostly pass.

    I'm not sure how you would perfectly check for this, but this has less of a chance of it passing without ever returning a maximum:

    var count = {1:0, 2:0};
    for(var i=0; i<100; i++) {
       count[dice(1,2)]++;
    }
    Test.expect(count[2]>0, "Did not return 2 out of 100 rolls of dice(1,2)");
    
  • Custom User Avatar

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

  • Custom User Avatar

    The more we talk, the more I think that the λ2 calculus isn't up to this task.

    (╯`д´)╯︵ ┻━┻ Time to drop haskell, climb the λ Cube, and redo everything Agda! Where's my axiom of infinity? I have a craving to construct ℕ from scratch...


    Kidding aside, for 8 kyu kata in other languages, the convention is to not sweat the corner cases...

    I think the way you did it (using undefined) is the most mathmatically sound way, but it gives no help in fixing the error (generic "Prelude.undefined" error message).

    Yeah, you're right. I just switched it from undefined to error "elementAt is not defined for non-positive input"

  • Custom User Avatar

    I agree in both cases (don't like errors, too early for Maybe). I guess the main question is, do we want the Kata to be opinionated, or should it leave it up to the user?

    Since the problem isn't defined for k <= 0, you can't just fill in a value. It also hides problems when using elementAt.

    I think the way you did it (using undefined) is the most mathmatically sound way, but it gives no help in fixing the error (generic "Prelude.undefined" error message).

    I think returning a specific error message will help with debugging. So I would vote for expecting an error to be thrown.

  • Custom User Avatar

    Perhaps it should throw an exception like the built-in (!!). Personally, I don't like throwing exceptions, so I'd rather return Maybe a instead. However, since this is an absolute beginner kata I don't think this is a good place to introduce Maybe...

  • Custom User Avatar

    One problem I had with this on the 99 questions originally is it doesn't say what 0 or less should return. It is left up to the programmer to think about what that means. Shouldn't that be specified?