iterate package:rio

iterate f x returns an infinite ByteString of repeated applications of f to x:
iterate f x == [x, f x, f (f x), ...]
iterate f x returns an infinite list of repeated applications of f to x:
iterate f x == [x, f x, f (f x), ...]
Note that iterate is lazy, potentially leading to thunk build-up if the consumer doesn't force each iterate. See iterate' for a strict variant of this function.
iterate f x produces the infinite sequence of repeated applications of f to x.
iterate f x = x :| [f x, f (f x), ..]
iterate f x returns an infinite Text of repeated applications of f to x:
iterate f x == [x, f x, f (f x), ...]
Constructs a sequence by repeated application of a function to a seed value.
iterateN n f x = fromList (Prelude.take n (Prelude.iterate f x))
O(n) Apply function <math> times to an initial value, producing a vector of length <math>. Zeroth element will contain the initial value, that's why there is one less function application than the number of elements in the produced vector. <math>
O(n) Apply monadic function <math> times to an initial value, producing a vector of length <math>. Zeroth element will contain the initial value, that's why there is one less function application than the number of elements in the produced vector. For non-monadic version see iterateN
O(n) Apply function <math> times to an initial value, producing a vector of length <math>. Zeroth element will contain the initial value, that's why there is one less function application than the number of elements in the produced vector. <math>

Examples

>>> import qualified Data.Vector as V

>>> V.iterateN 0 undefined undefined :: V.Vector String
[]

>>> V.iterateN 4 (\x -> x <> x) "Hi"
["Hi","HiHi","HiHiHiHi","HiHiHiHiHiHiHiHi"]
O(n) Apply monadic function <math> times to an initial value, producing a vector of length <math>. Zeroth element will contain the initial value, that's why there is one less function application than the number of elements in the produced vector. For non-monadic version see iterateN
O(n) Apply function <math> times to an initial value, producing a vector of length <math>. Zeroth element will contain the initial value, that's why there is one less function application than the number of elements in the produced vector. <math>

Examples

>>> import qualified Data.Vector.Storable as VS

>>> VS.iterateN 0 undefined undefined :: VS.Vector Int
[]

>>> VS.iterateN 26 succ 'a'
"abcdefghijklmnopqrstuvwxyz"
O(n) Apply monadic function <math> times to an initial value, producing a vector of length <math>. Zeroth element will contain the initial value, that's why there is one less function application than the number of elements in the produced vector. For non-monadic version see iterateN
O(n) Apply function <math> times to an initial value, producing a vector of length <math>. Zeroth element will contain the initial value, that's why there is one less function application than the number of elements in the produced vector. <math>

Examples

>>> import qualified Data.Vector.Unboxed as VU

>>> VU.iterateN 0 undefined undefined :: VU.Vector Int
[]

>>> VU.iterateN 3 (\(i, c) -> (pred i, succ c)) (0 :: Int, 'a')
[(0,'a'),(-1,'b'),(-2,'c')]
O(n) Apply monadic function <math> times to an initial value, producing a vector of length <math>. Zeroth element will contain the initial value, that's why there is one less function application than the number of elements in the produced vector. For non-monadic version see iterateN