enumFromThenTo -package:prelude-safeenum

Used in Haskell's translation of [n,n'..m] with [n,n'..m] = enumFromThenTo n n' m, a possible implementation being enumFromThenTo n n' m = worker (f x) (c x) n m, x = fromEnum n' - fromEnum n, c x = bool (>=) ((x 0)
f n y
| n > 0 = f (n - 1) (succ y)
| n < 0 = f (n + 1) (pred y)
| otherwise = y

and
worker s c v m
| c v m = v : worker s c (s v) m
| otherwise = []

Examples

  • enumFromThenTo 4 2 -6 :: [Integer] =
    [4,2,0,-2,-4,-6]
  • enumFromThenTo 6 8 2 :: [Int] = []
O(n) Enumerate values from x to y with a specific step z. WARNING: This operation can be very inefficient. If possible, use enumFromStepN instead.
Enumerate values with a given step. WARNING: This operations is very inefficient. If at all possible, use enumFromStepN instead.
Enumerate values with a given step. WARNING: This operation is very inefficient. If at all possible, use enumFromStepN instead.
O(n) Enumerate values from x to y with a specific step z. WARNING: This operation can be very inefficient. If possible, use enumFromStepN instead.
O(n) Enumerate values from x to y with a specific step z. WARNING: This operation can be very inefficient. If possible, use enumFromStepN instead.
O(n) Enumerate values from x to y with a specific step z. WARNING: This operation can be very inefficient. If possible, use enumFromStepN instead.
O(n) Enumerate values from x to y with a specific step z. WARNING: This operation can be very inefficient. If possible, use enumFromStepN instead.
Used in Haskell's translation of [n,n'..m] with [n,n'..m] = enumFromThenTo n n' m, a possible implementation being enumFromThenTo n n' m = worker (f x) (c x) n m, x = fromEnum n' - fromEnum n, c x = bool (>=) ((x 0) f n y | n > 0 = f (n - 1) (succ y) | n < 0 = f (n + 1) (pred y) | otherwise = y and worker s c v m | c v m = v : worker s c (s v) m | otherwise = [] For example:
  • enumFromThenTo 4 2 -6 :: [Integer] =
    [4,2,0,-2,-4,-6]
  • enumFromThenTo 6 8 2 :: [Int] = []
O(n) Enumerate values from x to y with a specific step z. WARNING: This operation can be very inefficient. If at all possible, use enumFromStepN instead.
O(n) Enumerate values from x to y with a specific step z. WARNING: This operation can be very inefficient. If at all possible, use enumFromStepN instead.
O(n) Enumerate values from x to y with a specific step z. WARNING: This operation can be very inefficient. If at all possible, use enumFromStepN instead.
O(n) Enumerate values from x to y with a specific step z. WARNING: This operation can be very inefficient. If at all possible, use enumFromStepN instead.
Used in Haskell's translation of [n,n'..m].
enumFromThenTo m n. Symbolic version of [m, m' .. n]
O(n) Enumerate values from x to y with a specific step z. If an enumeration does not use meaningful indices, Nothing is returned, otherwise, Just containing a non-empty vector. WARNING: This operation can be very inefficient. If at all possible, use enumFromStepN instead.
Enumerate values with a given step. WARNING: This operation is very inefficient. If at all possible, use enumFromStepN instead.
bounded arithmetic sequence, with first two elements given [from, then .. to]