iterateN package:rio
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 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 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 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
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 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 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