Hoogle Search

Within LTS Haskell 24.6 (ghc-9.10.2)

Note that Stackage only displays results for the latest LTS and Nightly snapshot. Learn more.

  1. foldlP :: (MonadIO m, Index ix, Source r e) => (a -> e -> a) -> a -> (b -> a -> b) -> b -> Array r ix e -> m b

    massiv Data.Massiv.Array

    O(n) - Left fold, computed with respect of array's computation strategy. Because we do potentially split the folding among many threads, we also need a combining function and an accumulator for the results. Depending on the number of threads being used, results can be different, hence is the MonadIO constraint.

    Examples

    >>> import Data.Massiv.Array
    
    >>> foldlP (flip (:)) [] (flip (:)) [] $ makeArrayR D Seq (Sz1 6) id
    [[5,4,3,2,1,0]]
    
    >>> foldlP (flip (:)) [] (++) [] $ makeArrayR D Seq (Sz1 6) id
    [5,4,3,2,1,0]
    
    >>> foldlP (flip (:)) [] (flip (:)) [] $ makeArrayR D (ParN 3) (Sz1 6) id
    [[5,4],[3,2],[1,0]]
    
    >>> foldlP (flip (:)) [] (++) [] $ makeArrayR D (ParN 3) (Sz1 6) id
    [1,0,3,2,5,4]
    

  2. foldlS :: (Index ix, Source r e) => (a -> e -> a) -> a -> Array r ix e -> a

    massiv Data.Massiv.Array

    O(n) - Left fold, computed sequentially.

  3. foldlWithin :: forall ix (n :: Natural) r e a . (Index (Lower ix), IsIndexDimension ix n, Source r e) => Dimension n -> (a -> e -> a) -> a -> Array r ix e -> Array D (Lower ix) a

    massiv Data.Massiv.Array

    Left fold along a specified dimension.

    Example

    >>> import Data.Massiv.Array
    
    >>> :set -XTypeApplications
    
    >>> arr = makeArrayLinear @U Seq (Sz (2 :. 5)) id
    
    >>> arr
    Array U Seq (Sz (2 :. 5))
    [ [ 0, 1, 2, 3, 4 ]
    , [ 5, 6, 7, 8, 9 ]
    ]
    
    >>> foldlWithin Dim1 (flip (:)) [] arr
    Array D Seq (Sz1 2)
    [ [4,3,2,1,0], [9,8,7,6,5] ]
    
    >>> foldlWithin Dim2 (flip (:)) [] arr
    Array D Seq (Sz1 5)
    [ [5,0], [6,1], [7,2], [8,3], [9,4] ]
    

  4. foldlWithin' :: (HasCallStack, Index (Lower ix), Index ix, Source r e) => Dim -> (a -> e -> a) -> a -> Array r ix e -> Array D (Lower ix) a

    massiv Data.Massiv.Array

    Similar to foldlWithin, except that dimension is specified at a value level, which means it will throw an exception on an invalid dimension.

  5. foldlStencil :: Index ix => (a -> e -> a) -> a -> Sz ix -> Stencil ix e a

    massiv Data.Massiv.Array.Stencil

    Stencil that does a left fold in a row-major order. Regardless of the supplied size resulting stencil will be centered at zero, although by using Padding it is possible to overcome this limitation.

    Examples

    >>> import Data.Massiv.Array as A
    
    >>> a = computeAs P $ iterateN (Sz2 3 4) (+1) (10 :: Int)
    
    >>> a
    Array P Seq (Sz (3 :. 4))
    [ [ 11, 12, 13, 14 ]
    , [ 15, 16, 17, 18 ]
    , [ 19, 20, 21, 22 ]
    ]
    
    >>> applyStencil noPadding (foldlStencil (flip (:)) [] (Sz2 3 2)) a
    Array DW Seq (Sz (1 :. 3))
    [ [ [20,19,16,15,12,11], [21,20,17,16,13,12], [22,21,18,17,14,13] ]
    ]
    
    >>> applyStencil (Padding (Sz2 1 0) 0 (Fill 10)) (foldlStencil (flip (:)) [] (Sz2 3 2)) a
    Array DW Seq (Sz (2 :. 3))
    [ [ [16,15,12,11,10,10], [17,16,13,12,10,10], [18,17,14,13,10,10] ]
    , [ [20,19,16,15,12,11], [21,20,17,16,13,12], [22,21,18,17,14,13] ]
    ]
    

  6. foldlIndex :: Index ix => (a -> Int -> a) -> a -> ix -> a

    massiv Data.Massiv.Core.Index

    Perform a left fold over the index

  7. foldlUnliftedArray :: PrimUnlifted a => (b -> a -> b) -> b -> UnliftedArray a -> b

    primitive-unlifted Data.Primitive.Unlifted.Array

    Lazy left-associated fold over the elements of an UnliftedArray.

  8. foldlUnliftedArray' :: PrimUnlifted a => (b -> a -> b) -> b -> UnliftedArray a -> b

    primitive-unlifted Data.Primitive.Unlifted.Array

    Strict left-associated fold over the elements of an UnliftedArray.

  9. foldlUnliftedArrayM' :: (PrimUnlifted a, Monad m) => (b -> a -> m b) -> b -> UnliftedArray a -> m b

    primitive-unlifted Data.Primitive.Unlifted.Array

    Strict effectful left-associated fold over the elements of an UnliftedArray.

  10. foldlUnliftedArray :: PrimUnlifted a => (b -> a -> b) -> b -> UnliftedArray a -> b

    primitive-unlifted Data.Primitive.Unlifted.Array.ST

    Lazy left-associated fold over the elements of an UnliftedArray.

Page 55 of many | Previous | Next