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.
This kata only seems to work on GHC 8.2.
Is this kata broken? The default test suite is complaining about a missing main.
It's also doing too much work.
I think it would be a good idea to explicitly import the functions in the tests.
I defined "nil" in my implementation to make things a little easier, but I found that the final tests also defined this, so there was a name collision!
Guido hates the return type being dependent on argument values. That's why even 8/2 is 4.0 in sane Pythons, not 4. Although, of course, there is an exception. Can you tell what it is? :-]
This is a really nice solution!
My only qualm with it is that uniform is a partial function, so this solution would cause a runtime error when given an empty string.
This comment is hidden because it contains spoiler information about the solution
Oh good, I'm not crazy.
Please fix this!
Yeah, you're right about the Codewars grouping! The main one that shows up lacks the spacing, though! I assume this was the first such solution.
Take care! :)
You mean that you'd rather have
abs (x1-x2)
instead ofabs(x1-x2)
. That's right, it would be much more natural in Haskell. In fact, I think that's what I wrote, but I think that codewars ignores white space when grouping solutions.Having parenthesis right beside the function call in Haskell seems so strange to me! Nothing wrong with it, just don't see it much.
but since this is an easier problem if any of you are new to haskell it's worth noting that function calls don't actually require parenthesis like they do in other programming languages (such as Python, C, etc.)
f x
instead of
f(x)
is perfectly fine :). It's nice because you get less noise with all of the parenthesis. I'm sure lots of you know about this, but sometimes when people format things like this they're secretly trying to make Haskell one of their other favourite programming languages ;).
Cheers!
*Edit*: Sorry, completely misinterpreted your comment. I've added an issue to the kata and will add the
0
test as soon as #163 gets fixed.Given the definition of perfect square in this Kata this solution is actually not correct. You should have n >= 0 because 0 is a perfect square in this problem! :)
Kind of annoying having this expect "f(x) = x + -1" instead of "f(x) = x - 1".
Seems like it would be better to do the latter, since this is the format which is suggested by the description...
"the function will always be in the format "nx +/- m", 'x +/- m', 'nx', 'x' or 'm'"
I assumed that the output function would follow the same. There are not sufficient test cases by default to discern what output is desired in these cases, I think!
Otherwise this was cute :).
My issue is with the specification. I don't see why this function shouldn't just handle an empty string by returning an empty string anyway. Why make the function less general for no particular reason? It seems better practice to me to handle the case with the empty string.
Loading more items...