Hoogle Search
Within LTS Haskell 24.36 (ghc-9.10.3)
Note that Stackage only displays results for the latest LTS and Nightly snapshot. Learn more.
-
streamly-core Streamly.Internal.Data.Array chunksOf n stream groups the elements in the input stream into arrays of n elements each. Same as the following but may be more efficient:
>>> chunksOf n = Stream.foldMany (Array.writeN n)
Pre-release chunksOf :: forall (m :: Type -> Type) a . MonadIO m => Int -> Stream m a -> Stream m (Array a)streamly-core Streamly.Internal.Data.Array.Generic No documentation available.
-
streamly-core Streamly.Internal.Data.Array.Stream chunksOf n stream groups the elements in the input stream into arrays of n elements each. Same as the following but may be more efficient:
>>> chunksOf n = Stream.foldMany (Array.writeN n)
Pre-release -
streamly-core Streamly.Internal.Data.MutArray chunksOf n stream groups the elements in the input stream into arrays of n elements each. Same as the following but may be more efficient:
>>> chunksOf n = Stream.foldMany (MutArray.createOf n)
Pre-release chunksOf :: forall (m :: Type -> Type) a . MonadIO m => Int -> Stream m a -> Stream m (MutArray a)streamly-core Streamly.Internal.Data.MutArray.Generic chunksOf n stream groups the input stream into a stream of arrays of size n.
chunksOf n = foldMany (MutArray.writeN n)
Pre-release-
streamly-core Streamly.Internal.Data.MutArray.Stream chunksOf n stream groups the elements in the input stream into arrays of n elements each. Same as the following but may be more efficient:
>>> chunksOf n = Stream.foldMany (MutArray.createOf n)
Pre-release chunksOf :: Vector v a => Int -> v a -> [v a]vector-split Data.Vector.Split chunksOf n splits a vector into length-n pieces. The last piece will be shorter if n does not evenly divide the length of the vector. If n <= 0, chunksOf n l returns an infinite list of empty vectors. For example: Note that chunksOf n [] is [], not [[]]. This is intentional, and is consistent with a recursive definition of chunksOf; it satisfies the property that
chunksOf n xs ++ chunksOf n ys == chunksOf n (xs ++ ys)
whenever n evenly divides the length of xs.chunksOf :: Int -> Text -> [Text]miso Miso.String O(n) Splits a Text into components of length k. The last element may be shorter than the other chunks, depending on the length of the input. Examples:
>>> chunksOf 3 "foobarbaz" ["foo","bar","baz"]
>>> chunksOf 4 "haskell.org" ["hask","ell.","org"]
chunksOf :: Int -> Slist a -> Slist (Slist a)slist Slist O(n). Splits a Slist into components of the given length. The last element may be shorter than the other chunks, depending on the length of the input.
>>> chunksOf 3 $ slist [0..7] Slist {sList = [Slist {sList = [0,1,2], sSize = Size 3},Slist {sList = [3,4,5], sSize = Size 3},Slist {sList = [6,7], sSize = Size 2}], sSize = Size 3} >>> chunksOf 0 $ slist [0..10] Slist {sList = [], sSize = Size 0} >>> chunksOf (-13) $ slist [0..10] Slist {sList = [], sSize = Size 0} >>> chunksOf 100 $ slist [1,2,3] Slist {sList = [Slist {sList = [1,2,3], sSize = Size 3}], sSize = Size 1}>>> take 2 $ chunksOf 3 $ infiniteSlist [1..] Slist {sList = [Slist {sList = [1,2,3], sSize = Size 3},Slist {sList = [4,5,6], sSize = Size 3}], sSize = Size 2}-
streamly Streamly.Internal.Data.Stream.IsStream Group the input stream into groups of n elements each and then fold each group using the provided fold function.
>>> Stream.toList $ Stream.chunksOf 2 Fold.sum (Stream.enumerateFromTo 1 10) [3,7,11,15,19]
This can be considered as an n-fold version of take where we apply take repeatedly on the leftover stream until the stream exhausts.chunksOf n f = foldMany (FL.take n f)