The addition of 2 Fraction instance should yield a Fraction instance, not its string representation. That one we will have to leave it to str / repr to do the job.
The task is not defined. In Python and Haskell, one is asked to do very different things, actually one cannot rely on the description, but must guess hazardously from the initial code and sample tests.
Concretely, for example in Haskell, the initial code includes a definition for signum, abs and negate functions (what should they be?). There's no need to define them to pass the tests, but we get warnings from GHC's tests:
STDERR
src/Fraction.hs:18:10: warning: [-Wmissing-methods]
• No explicit implementation for
‘abs’, ‘signum’, and (either ‘negate’ or ‘-’)
• In the instance declaration for ‘Num Fraction’
|
18 | instance Num Fraction where
| ^^^^^^^^^^^^
True. I had wasted a lot of time thinking what went wrong until I saw your comment. By convention, the minus sign is never placed in the denominator in a reduced fraction. I think this should be an issue rather than a suggestion.
Approved fork, so this should be fixed.
Approved!
I've made a fork that checks that the solution class isn't a subclass of
fractions.Fraction
.I've made a fork that updates the description to more accurately describe the task for Python and Haskell.
This comment is hidden because it contains spoiler information about the solution
Merged
The addition of 2
Fraction
instance should yield aFraction
instance, not its string representation. That one we will have to leave it tostr
/repr
to do the job.python new test framework is required. updated in this fork
The task is not defined. In Python and Haskell, one is asked to do very different things, actually one cannot rely on the description, but must guess hazardously from the initial code and sample tests.
Concretely, for example in Haskell, the initial code includes a definition for signum, abs and negate functions (what should they be?). There's no need to define them to pass the tests, but we get warnings from GHC's tests:
What's the point?
This comment is hidden because it contains spoiler information about the solution
True. I had wasted a lot of time thinking what went wrong until I saw your comment. By convention, the minus sign is never placed in the denominator in a reduced fraction. I think this should be an issue rather than a suggestion.
Kotlin translation added. Please review.
https://www.codewars.com/kumite/6107bfd7bcc1ea0032702f92
I used the magic method repr and get lots of errors like '37/40 should equal 37/40'. Can somebody give my hint as to what is going on here?
Loading more items...