getNext a = if even a then a/2 else (3*a)+1
for some reason this line of code returns an unresolved overloading error.
Main> getNext 13
ERROR - Unresolved overloading
*** Type : (Fractional a, Integral a) => a
What am I doing wrong or what am I missing? I haven't used Haskell in quite some time so I might have forgotten a few things.
You probably want
a `div` 2
rather than
a/2
The error is happening because even a
implies that a
is an integer, but the use of the non-integer division operator /
implies otherwise.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With