В данном вопросе это не суть. Если он на [0, 5 .. 13] генерит мне [0, 5, 10, 15], то не я тут виноват, и то, что 13 с 15 сравнивать нельзя - не оправдание.
-- The Enum instances for Floats and Doubles are slightly unusual. -- The `toEnum' function truncates numbers to Int. The definitions -- of enumFrom and enumFromThen allow floats to be used in arithmetic -- series: [0,0.1 .. 0.95]. However, roundoff errors make these somewhat -- dubious. This example may have either 10 or 11 elements, depending on -- how 0.1 is represented. http://haskell.org/onlinereport/standard-prelude.html
[vlm@staging:~]> uname -a SunOS staging 5.10 Generic_118822-25 sun4u sparc SUNW,UltraAX-i2 [vlm@staging:~]> ghci GHCi, version 6.8.2: http://www.haskell.org/ghc/ :? for help Prelude> last ([0, 1 / 13 .. 1] :: [Double]) <= 1 True Prelude> Connection to staging closed. [vlm@nala:~]> uname -a Darwin nala 9.8.0 Darwin Kernel Version 9.8.0: Wed Jul 15 16:57:01 PDT 2009; root:xnu-1228.15.4~1/RELEASE_PPC Power Macintosh [vlm@nala:~]> ghci GHCi, version 6.10.2: http://www.haskell.org/ghc/ :? for help Prelude> last ([0, 1 / 13 .. 1] :: [Double]) <= 1 False Prelude>
Comments 15
Reply
Если он на [0, 5 .. 13] генерит мне [0, 5, 10, 15], то не я тут виноват, и то, что 13 с 15 сравнивать нельзя - не оправдание.
Reply
Reply
Prelude Data.List> [0, 1 / 13 .. 1] :: [Double]
[0.0,7.692307692307693e-2,0.15384615384615385,0.23076923076923078,
0.3076923076923077,0.38461538461538464,0.46153846153846156,0.5384615384615385,
0.6153846153846155,0.6923076923076925,0.7692307692307695,0.8461538461538465,
0.9230769230769235,1.0000000000000004]
Reply
-- The Enum instances for Floats and Doubles are slightly unusual.
-- The `toEnum' function truncates numbers to Int. The definitions
-- of enumFrom and enumFromThen allow floats to be used in arithmetic
-- series: [0,0.1 .. 0.95]. However, roundoff errors make these somewhat
-- dubious. This example may have either 10 or 11 elements, depending on
-- how 0.1 is represented.
http://haskell.org/onlinereport/standard-prelude.html
Reply
Reply
Пробуем GHCi, version 6.8.3
GHCi, version 6.8.3: http://www.haskell.org/ghc/ :? for help
Loading package base ... linking ... done.
Prelude> [0, 1 / 13 .. 1] :: [Double]
[0.0,7.692307692307693e-2,0.15384615384615385,0.23076923076923078,0.307692307692
3077,0.38461538461538464,0.46153846153846156,0.5384615384615385,0.61538461538461
54,0.6923076923076923,0.7692307692307692,0.846153846153846,0.9230769230769229,0.
9999999999999998]
Пробуем GHCi, version 6.10.4
GHCi, version 6.10.4: http://www.haskell.org/ghc/ :? for help ( ... )
Reply
За объяснение спасибо :)
Reply
Hugs> last ([0, 1 / 13 .. 1] :: [Double]) <= 1
True
Reply
SunOS staging 5.10 Generic_118822-25 sun4u sparc SUNW,UltraAX-i2
[vlm@staging:~]> ghci
GHCi, version 6.8.2: http://www.haskell.org/ghc/ :? for help
Prelude> last ([0, 1 / 13 .. 1] :: [Double]) <= 1
True
Prelude> Connection to staging closed.
[vlm@nala:~]> uname -a
Darwin nala 9.8.0 Darwin Kernel Version 9.8.0: Wed Jul 15 16:57:01 PDT 2009; root:xnu-1228.15.4~1/RELEASE_PPC Power Macintosh
[vlm@nala:~]> ghci
GHCi, version 6.10.2: http://www.haskell.org/ghc/ :? for help
Prelude> last ([0, 1 / 13 .. 1] :: [Double]) <= 1
False
Prelude>
Reply
GHCi, version 6.8.3: http://www.haskell.org/ghc/ :? for help
Loading package base ... linking ... done.
Prelude> [0, 1 / 13 .. 1] :: [Double]
[0.0,7.692307692307693e-2,0.15384615384615385,0.23076923076923078,0.307692307692
3077,0.38461538461538464,0.46153846153846156,0.5384615384615385,0.61538461538461
54,0.6923076923076923,0.7692307692307692,0.846153846153846,0.9230769230769229,0.
9999999999999998]
GHCi, version 6.10.4: http://www.haskell.org/ghc/ :? for help ( ... )
Reply
Prelude> [0,1/13..1.03]
[0.0,7.692307692307693e-2,0.15384615384615385,0.23076923076923078,0.3076923076923077,0.38461538461538464,0.46153846153846156,0.5384615384615385,0.6153846153846155,0.6923076923076925,0.7692307692307695,0.8461538461538465,0.9230769230769235,1.0000000000000004]
Prelude>
Reply
Prelude> [0,1/13..0.97]
[0.0,7.692307692307693e-2,0.15384615384615385,0.23076923076923078,0.3076923076923077,0.38461538461538464,0.46153846153846156,0.5384615384615385,0.6153846153846155,0.6923076923076925,0.7692307692307695,0.8461538461538465,0.9230769230769235,1.0000000000000004]
Prelude>
Reply
Leave a comment