foldable-ix-0.3.0.0: Functions to find out the indices of the elements in the Foldable structures
Copyright(c) OleksandrZhabenko 2020-2023
LicenseMIT
Maintaineroleksandr.zhabenko@yahoo.com
StabilityExperimental
Safe HaskellSafe-Inferred
LanguageHaskell2010
Extensions
  • Cpp
  • BangPatterns

Data.Foldable.Ix

Description

 
Synopsis

Documentation

data OneInTwoBang a b Source #

Constructors

B12 !a !b 

Instances

Instances details
(Eq a, Eq b) => Eq (OneInTwoBang a b) Source # 
Instance details

Defined in Data.Foldable.Ix

Methods

(==) :: OneInTwoBang a b -> OneInTwoBang a b -> Bool #

(/=) :: OneInTwoBang a b -> OneInTwoBang a b -> Bool #

data ThreeInFourBang a b Source #

Constructors

B34 b !b ![a] 

Instances

Instances details
(Eq b, Eq a) => Eq (ThreeInFourBang a b) Source # 
Instance details

Defined in Data.Foldable.Ix

findIdx1 :: (Eq a, Foldable t, Integral b) => a -> t a -> Maybe b Source #

Function to find out the 'index' (as the reperesentative of the Integral class) of the first element in the Foldable structure (from the left with indices starting from 0), which equals to the first argument. Returns Nothing if there are no such elements.

findIdx1' :: (Eq a, Foldable t) => a -> t a -> Maybe Int Source #

findIdxs :: (Eq a, Foldable t) => a -> t a -> [Int] Source #

Function to find out the 'indices' of the elements in the Foldable structure (from the left with indices starting from 0) that equal to the first argument. Returns empty list if there are no such elements. Uses two passes through the structure.

findIdxsL1 :: (Eq a, Foldable t) => a -> t a -> [Int] Source #

Function to find out the 'indices' of the elements in the Foldable structure (from the left with indices starting from 0) that equal to the first argument. Returns empty list if there are no such elements. Uses just one pass through the structure and additional reverse operation on the resulting list with foldl'.

sliceToList :: (Eq a, Foldable t) => Int -> Int -> t a -> [a] Source #

Inspired by the Data.Vector.slice function from the vector package. Takes a 'slice' for the Foldable structure converting it to the list. The first argument is the 'index' of the element in the structure starting from 0 from the left. The second one is the length of the slice.

s2L :: Eq a => Int -> Int -> [a] -> [a] Source #