module Stan.Core.List
( checkWith
, nonRepeatingPairs
) where
checkWith :: (a -> b -> Bool) -> [a] -> [b] -> Bool
checkWith :: (a -> b -> Bool) -> [a] -> [b] -> Bool
checkWith _ [] [] = Bool
True
checkWith _ [] _ = Bool
False
checkWith _ _ [] = Bool
False
checkWith f :: a -> b -> Bool
f (a :: a
a:as :: [a]
as) (b :: b
b:bs :: [b]
bs) = a -> b -> Bool
f a
a b
b Bool -> Bool -> Bool
&& (a -> b -> Bool) -> [a] -> [b] -> Bool
forall a b. (a -> b -> Bool) -> [a] -> [b] -> Bool
checkWith a -> b -> Bool
f [a]
as [b]
bs
nonRepeatingPairs :: [a] -> [(a, a)]
nonRepeatingPairs :: [a] -> [(a, a)]
nonRepeatingPairs [] = []
nonRepeatingPairs (x :: a
x:xs :: [a]
xs) = (a -> (a, a)) -> [a] -> [(a, a)]
forall a b. (a -> b) -> [a] -> [b]
map (a
x,) [a]
xs [(a, a)] -> [(a, a)] -> [(a, a)]
forall a. [a] -> [a] -> [a]
++ [a] -> [(a, a)]
forall a. [a] -> [(a, a)]
nonRepeatingPairs [a]
xs