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 comment is hidden because it contains spoiler information about the solution
Q: Does this have a problem with empty input?
x:xs needs to be wrapped in parentheses
I've read about a proposal. But it doesn't matter, since my argument was of hypothetical nature. The
Show
class is used to produce a text representation of a value, which can be easily read back in with theRead
class, and nothing more.Isn't
2e4 :: Fractional a => a
per section 2.5? Do you have a link for2e4 :: Num a => a
? Also, section 9 specifiesinstance Show Integer
asshowsPrec = showSigned showInt
, which shows an integral number in base 10.That's exactly the point. And what if they allow
20000
to be written as a new kind of literal2e4
, then it could also be reflected in theShow
instance.People make assumptions about things, which probably will not hold. Bad code style.
You can even eta reduce that snippet to
digits = map digitToInt . show
. Either way, this will fail on negative input, such as-1234563
.maybe this?
import Data.Char
digits :: Integer -> [Int]
digits n = (map digitToInt).show n
although it seems useless to convert char to int since char itself can be sorted.
This comment is hidden because it contains spoiler information about the solution