Copyright | (C) Frank Staals David Himmelstrup |
---|---|
License | see the LICENSE file |
Maintainer | David Himmelstrup |
Safe Haskell | None |
Language | Haskell2010 |
Synopsis
- item :: Int -> Lens' (CircularVector a) a
- rightElements :: CircularVector a -> NonEmptyVector a
- leftElements :: CircularVector a -> NonEmptyVector a
- findRotateTo :: (a -> Bool) -> CircularVector a -> Maybe (CircularVector a)
- isShiftOf :: Eq a => CircularVector a -> CircularVector a -> Bool
- withIndicesRight :: CircularVector a -> CircularVector (Int :+ a)
Documentation
item :: Int -> Lens' (CircularVector a) a Source #
Access the ith item in the CircularVector (w.r.t the rotation) as a lens
rightElements :: CircularVector a -> NonEmptyVector a Source #
All elements, starting with the focus, going to the right
>>>
rightElements $ unsafeFromList [3,4,5,1,2]
[3,4,5,1,2]
leftElements :: CircularVector a -> NonEmptyVector a Source #
All elements, starting with the focus, going to the left
>>>
leftElements $ unsafeFromList [3,4,5,1,2]
[3,2,1,5,4]
findRotateTo :: (a -> Bool) -> CircularVector a -> Maybe (CircularVector a) Source #
Finds an element in the CircularVector
>>>
findRotateTo (== 3) $ unsafeFromList [1..5]
Just (CircularVector {vector = [1,2,3,4,5], rotation = 2})>>>
findRotateTo (== 7) $ unsafeFromList [1..5]
Nothing
isShiftOf :: Eq a => CircularVector a -> CircularVector a -> Bool Source #
Test if the circular list is a cyclic shift of the second list.
Running time: \(O(n+m)\), where \(n\) and \(m\) are the sizes of the lists.
withIndicesRight :: CircularVector a -> CircularVector (Int :+ a) Source #
label the circular vector with indices, starting from zero at the current focus, going right.
Running time: \(O(n)\)
Orphan instances
Foldable1 NonEmptyVector Source # | |
fold1 :: Semigroup m => NonEmptyVector m -> m # foldMap1 :: Semigroup m => (a -> m) -> NonEmptyVector a -> m # toNonEmpty :: NonEmptyVector a -> NonEmpty a # | |
Arbitrary a => Arbitrary (CircularVector a) Source # | |
arbitrary :: Gen (CircularVector a) # shrink :: CircularVector a -> [CircularVector a] # |