hgeometry-combinatorial-0.12.0.0: Data structures, and Data types.
Copyright(C) Frank Staals David Himmelstrup
Licensesee the LICENSE file
MaintainerDavid Himmelstrup
Safe HaskellNone
LanguageHaskell2010

Data.Vector.Circular.Util

Description

 
Synopsis

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 # 
Instance details

Methods

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 # 
Instance details