Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
Documentation
Simple Zipper for Lists.
Zipper [a] [a] |
Instances
Functor Zipper Source # | |
Foldable Zipper Source # | |
Defined in Data.List.Zipper fold :: Monoid m => Zipper m -> m # foldMap :: Monoid m => (a -> m) -> Zipper a -> m # foldr :: (a -> b -> b) -> b -> Zipper a -> b # foldr' :: (a -> b -> b) -> b -> Zipper a -> b # foldl :: (b -> a -> b) -> b -> Zipper a -> b # foldl' :: (b -> a -> b) -> b -> Zipper a -> b # foldr1 :: (a -> a -> a) -> Zipper a -> a # foldl1 :: (a -> a -> a) -> Zipper a -> a # elem :: Eq a => a -> Zipper a -> Bool # maximum :: Ord a => Zipper a -> a # minimum :: Ord a => Zipper a -> a # | |
Eq a => Eq (Zipper a) Source # | |
Show a => Show (Zipper a) Source # | |
allNexts :: Zipper a -> [Zipper a] Source #
Computes all nexts, even one that has no elements initially or at the end.
>>>
mapM_ print $ allNexts $ fromList [1..5]
Zipper [] [1,2,3,4,5] Zipper [1] [2,3,4,5] Zipper [2,1] [3,4,5] Zipper [3,2,1] [4,5] Zipper [4,3,2,1] [5] Zipper [5,4,3,2,1] []
extractNext :: Zipper a -> Maybe (a, Zipper a) Source #
Returns the next element, and the zipper without it
dropNext :: Zipper a -> Maybe (Zipper a) Source #
Drops the next element in the zipper.
running time: \(O(1)\)
allNonEmptyNexts :: Zipper a -> [Zipper a] Source #
Computes all list that still have next elements.
>>>
mapM_ print $ allNonEmptyNexts $ fromList [1..5]
Zipper [] [1,2,3,4,5] Zipper [1] [2,3,4,5] Zipper [2,1] [3,4,5] Zipper [3,2,1] [4,5] Zipper [4,3,2,1] [5]