On Mon, 21 Jan 2013, mip...@meta.ua wrote:
The program looks like this:
--***********************
factorial :: Int->Int
factorial n = product [1..n]
main = do
print $ factorial 50
--***********************
And that yields "0" (no errors). Is it a bug or feature? :)
This question is certainly better posted to haskell-cafe.
The answer is: Int has limited bitsize (32 ord 64 bit depending on your
machine), thus it computes factorial modulo 2^32 or 2^64. You can get the
correct result by replacing Int by Integer.
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe