Re: [Haskell-cafe] The range operator
At 12:28 07/04/2008, you wrote:
On Fri, Apr 4, 2008 at 10:49 PM, Andrew Coppin <andrewcoppin@btinternet.com> wrote:
More to the point, the range y..z goes in steps of y-z. ;-) [x,y..z] goes in steps of y-x ;-), [y..z] goes in steps of 1 (depending on the type).
Could you elaborate please?
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
class Enum a where ... -- | Used in Haskell's translation of [n,n'..m]. enumFromThenTo :: a -> a -> a -> [a] So [x, y .. z] becomes "enumFromThenTo x y z". Each instance of Enum is free to implement enumFromThenTo and friends in any way it likes. So with Ints you have [1, 3 .. 10] :: [Int] == [1, 3, 5, 7, 9] but with Chars you get ['a', 'c' .. 'i'] :: [Char] == "acegi" and with Floats you curiously get [1, 3 .. 10] :: [Float] == [1.0, 3.0, 5.0, 7.0, 9.0, 11.0] On Mon, Apr 7, 2008 at 2:07 PM, PR Stanley <prstanley@ntlworld.com> wrote:
At 12:28 07/04/2008, you wrote:
On Fri, Apr 4, 2008 at 10:49 PM, Andrew Coppin <andrewcoppin@btinternet.com> wrote:
More to the point, the range y..z goes in steps of y-z. ;-) [x,y..z] goes in steps of y-x ;-), [y..z] goes in steps of 1 (depending on the type).
Could you elaborate please?
participants (2)
-
PR Stanley -
Roel van Dijk