module Stan.Core.List
( checkWith
, nonRepeatingPairs
) where
checkWith :: (a -> b -> Bool) -> [a] -> [b] -> Bool
checkWith :: forall a b. (a -> b -> Bool) -> [a] -> [b] -> Bool
checkWith a -> b -> Bool
_ [] [] = Bool
True
checkWith a -> b -> Bool
_ [] [b]
_ = Bool
False
checkWith a -> b -> Bool
_ [a]
_ [] = Bool
False
checkWith a -> b -> Bool
f (a
a:[a]
as) (b
b:[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 :: forall a. [a] -> [(a, a)]
nonRepeatingPairs [] = []
nonRepeatingPairs (a
x:[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