A data type with O(1) take/drop using an array as the underlying storage.
newtype Slice a
Represents a slice of an array.
slice :: forall a. [a] -> Slice a
Create a slice from an array.
sarray :: forall a. Slice a -> [a]
Construct a new array from a slice.
sempty :: forall a. Slice a
Constructor for the empty slice.
sat :: forall a. Slice a -> Number -> Maybe a
Access an element at an index.
seq :: forall a. (Eq a) => Slice a -> Slice a -> Boolean
Equality test.
sdrop :: forall a. Number -> Slice a -> Slice a
Drop a number of elements from the start of a slice, creating a new slice (O(1)).
stake :: forall a. Number -> Slice a -> Slice a
Keep only a number of elements from the start of a slice, creating a new slice (O(1)).
shead :: forall a. Slice a -> Maybe a
Get the first element in a slice, or Nothing
if the slice is empty.
slast :: forall a. Slice a -> Maybe a
Get the last element in a slice, or Nothing
if the slice is empty.
sinit :: forall a. Slice a -> Maybe (Slice a)
Get all but the last element of a slice, creating a new slice,
or Nothing
if the slice is empty (O(1)).
stail :: forall a. Slice a -> Maybe (Slice a)
Get all but the first element of a slice, creating a new slice,
or Nothing
if the slice is empty (O(1)).
snull :: forall a. Slice a -> Boolean
Test whether a slice is empty.
sappend :: forall a. Slice a -> Slice a -> Slice a
Concatenate two slices, creating a new slice.
sconcat :: forall a. Slice (Slice a) -> Slice a
Flatten a slice of slices, creating a new slice
sconcatMap :: forall a b. (a -> Slice b) -> Slice a -> Slice b
Apply a function to each element in an array, and flatten the results into a single, new array.
sfind :: forall a. (a -> Boolean) -> Slice a -> Number
Find the first index for which a predicate holds,
or -1
if no such element exists.
sfindLast :: forall a. (a -> Boolean) -> Slice a -> Number
Find the last index for which a predicate holds,
or -1
if no such element exists.
smap :: forall a b. (a -> b) -> Slice a -> Slice b
Apply a function to each element in a slice, creating a new slice.
sfoldl :: forall a b. (b -> a -> b) -> b -> Slice a -> b
Apply a left-folding function to a slice.
sfoldr :: forall a b. (a -> b -> b) -> b -> Slice a -> b
Apply a right-folding function to a slice.
szipWith :: forall a b c. (a -> b -> c) -> Slice a -> Slice b -> Slice c
Apply a function to pairs of elements at the same index in two slices, collecting the results in a new slice.
If one slice is longer, elements will be discarded from the longer slice.
For example
szipWith (*) (slice [1, 2, 3]) (slice [4, 5, 6, 7]) == slice [4, 10, 18]
instance showSlice :: (Show a) => Show (Slice a)
instance semigroupSlice :: Semigroup (Slice a)
instance monoidSlice :: Monoid (Slice a)
instance foldableSlice :: Foldable Slice
instance eqSlice :: (Eq a) => Eq (Slice a)
instance functorSlice :: Functor Slice
instance applySlice :: Apply Slice
instance applicativeSlice :: Applicative Slice
instance bindSlice :: Bind Slice
instance monadSlice :: Monad Slice
instance altSlice :: Alt Slice
instance plusSlice :: Plus Slice
instance alternativeSlice :: Alternative Slice
instance monadPlusSlice :: MonadPlus Slice