Commit before changing thingsHit to use stream
This commit is contained in:
@@ -7,6 +7,7 @@ module FoldableHelp
|
||||
, safeMinMaybeL
|
||||
, filter3
|
||||
, takeUntil
|
||||
, ssfold
|
||||
, module Data.Foldable
|
||||
)
|
||||
where
|
||||
@@ -91,3 +92,11 @@ filter3 t1 t2 t3 = L.fold $ (,,)
|
||||
-}
|
||||
takeUntil :: Foldable t => (a -> Bool) -> t a -> [a]
|
||||
takeUntil p = foldr (\x xs -> x : if p x then [] else xs) []
|
||||
|
||||
-- from haskell-cafe
|
||||
-- short circuit a fold when a given property is satisfied
|
||||
-- the fold builds a function that is then called on a0
|
||||
ssfold :: Foldable t => (a -> Bool) -> (a -> b -> a) -> a -> t b -> a
|
||||
{-# INLINABLE ssfold #-}
|
||||
ssfold p f a0 xs = foldr (\x g a -> if p a then a else g (f a x)) id xs a0
|
||||
|
||||
|
||||
Reference in New Issue
Block a user