@@ -599,11 +599,6 @@ module Data.Array where
599 filter p (x:xs) | p x = x : filter p xs
599 filter p (x:xs) | p x = x : filter p xs
600 filter p (_:xs) = filter p xs
600 filter p (_:xs) = filter p xs
602− find :: forall a. (a -> Boolean) -> [a] -> Maybe a
604− find p (x:xs) | p x = Just x
605− find p (_:xs) = find p xs
607 isEmpty :: forall a. [a] -> Boolean
602 isEmpty :: forall a. [a] -> Boolean
608 isEmpty [] = true
603 isEmpty [] = true
609 isEmpty _ = false
604 isEmpty _ = false
@@ -616,14 +611,6 @@ module Data.Array where
616 zipWith f (a:as) (b:bs) = f a b : zipWith f as bs
611 zipWith f (a:as) (b:bs) = f a b : zipWith f as bs
617 zipWith _ _ _ = []
612 zipWith _ _ _ = []
619− any :: forall a. (a -> Boolean) -> [a] -> Boolean
621− any p (a:as) = p a || any p as
623− all :: forall a. (a -> Boolean) -> [a] -> Boolean
625− all p (a:as) = p a && all p as
627 drop :: forall a. Number -> [a] -> [a]
614 drop :: forall a. Number -> [a] -> [a]
628 drop 0 xs = xs
615 drop 0 xs = xs
629 drop _ [] = []
616 drop _ [] = []
@@ -1295,6 +1282,35 @@ module Data.Foldable where
1295 mconcat :: forall f m. (Foldable f, Monoid m) => f m -> m
1282 mconcat :: forall f m. (Foldable f, Monoid m) => f m -> m
1296 mconcat = foldl (<>) mempty
1283 mconcat = foldl (<>) mempty
1285+ and :: forall f. (Foldable f) => f Boolean -> Boolean
1286+ and = foldl (&&) true
1288+ or :: forall f. (Foldable f) => f Boolean -> Boolean
1289+ or = foldl (||) false
1291+ any :: forall a f. (Foldable f) => (a -> Boolean) -> f a -> Boolean
1292+ any p = or <<< foldMap (\x -> [p x])
1294+ all :: forall a f. (Foldable f) => (a -> Boolean) -> f a -> Boolean
1295+ all p = and <<< foldMap (\x -> [p x])
1297+ sum :: forall f. (Foldable f) => f Number -> Number
1300+ product :: forall f. (Foldable f) => f Number -> Number
1301+ product = foldl (*) 1
1303+ elem :: forall a f. (Eq a, Foldable f) => a -> f a -> Boolean
1304+ elem = any <<< (==)
1306+ notElem :: forall a f. (Eq a, Foldable f) => a -> f a -> Boolean
1307+ notElem x = not <<< elem x
1309+ find :: forall a f. (Foldable f) => (a -> Boolean) -> f a -> Maybe a
1310+ find p f = case foldMap (\x -> if p x then [x] else []) f of
1298module Data.Traversable where
1314module Data.Traversable where
1300 import Prelude
1316 import Prelude