Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
what method slice doing here?
Resolved.
Fixed with your suggestion, thanks :)
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")
Mispellings and grammer errors. Suggest:
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:
This comment is hidden because it contains spoiler information about the solution
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...
Yeah, you're right. I just switched it from
undefined
toerror "elementAt is not defined for non-positive input"
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.
Perhaps it should throw an exception like the built-in
(!!)
. Personally, I don't like throwing exceptions, so I'd rather returnMaybe a
instead. However, since this is an absolute beginner kata I don't think this is a good place to introduceMaybe
...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?