enumFromThenTo -package:hledger-web

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.
Enumerate values with an inferred stride and a given limit. If x precedes y (and therefore we're enumerating forward) but x succeeds z (and therefore is past the limit), then the result is empty. Similarly, if x succeeds y (and therefore we're enumerating backward) but x precedes z (and therefore is past the limit), then the result is empty. Otherwise the result is non-empty since it contains x. Naturally, this should agree with enumFromTo and enumDownFromTo (assuming Eq a, by magic if need be):
if succ x == Just y then enumFromThenTo x y z == enumFromTo x z
if pred x == Just y then enumFromThenTo x y z == enumDownFromTo x z
In the default implementation: if fromEnum fails on any argument, then the result is either [] or [x] (as appropriate); and if toEnum fails on any of the enumerated integers, then the first failure terminates the enumeration. If either of these properties is inappropriate, then you should override the default. In GHC, the default implementation is a "good producer" for list fusion.
bounded arithmetic sequence, with first two elements given [from, then .. to]