module Solutions.P41 (goldbachList) where
import Problems.P40
goldbachList :: Integral a => a -> a -> [(a,a)]
goldbachList :: forall a. Integral a => a -> a -> [(a, a)]
goldbachList a
m a
n = (a -> (a, a)) -> [a] -> [(a, a)]
forall a b. (a -> b) -> [a] -> [b]
map a -> (a, a)
forall a. Integral a => a -> (a, a)
goldbach ([a] -> [(a, a)]) -> [a] -> [(a, a)]
forall a b. (a -> b) -> a -> b
$ (a -> Bool) -> [a] -> [a]
forall a. (a -> Bool) -> [a] -> [a]
takeWhile (a
n >=) [a
m',a
m'a -> a -> a
forall a. Num a => a -> a -> a
+a
2..]
where m' :: a
m' | a
m a -> a -> Bool
forall a. Ord a => a -> a -> Bool
<= a
2 = a
4
| a -> Bool
forall a. Integral a => a -> Bool
even a
m = a
m
| Bool
otherwise = a
ma -> a -> a
forall a. Num a => a -> a -> a
+a
1