
Hi, I think the problem is in the types. If you look at the type of the function round, you can see its result is an Integral:
:t round round :: (Integral b, RealFrac a) => a -> b
The result of the division x/y, instead, is a Fractional, and you cannot
test equality between two things of different types.
To solve the problem you can do a type cast, by converting the Integral to
a Num, using fromInteger:
(fromInteger (round (x/y))) == (x/y)
This should work.
Cheers,
Ut
Il giorno mer 8 gen 2020 alle ore 16:01 Alexander Chen
hi,
for a List comprehension I want to only include the integers of a division. In my beginners mind this should work:
(round (x / y)) == (x / y)
however, i get a nontrivial error blurp.
what am i doing wrong?
best,
Alexander
_______________________________________________ Beginners mailing list Beginners@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners