Successive prime differences: Difference between revisions

Content added Content deleted
Line 633: Line 633:
<lang haskell>import Data.Numbers.Primes (primes)
<lang haskell>import Data.Numbers.Primes (primes)


-- Type alias dictionary. Key is difference and value is a successive primes.
-- Type alias dictionary. Key is the difference group and value is a successive prime group.
type Result = [(String, [Int])]
type Result = [(String, [Int])]


Line 644: Line 644:
| otherwise = loopDiffs ds
| otherwise = loopDiffs ds
where successive = take (length d + 1) primes
where successive = take (length d + 1) primes
subs [] = []
subs = map (uncurry (-)) . init . tail . (\xs -> zip (xs <> [0]) (0 : xs))
subs p@(x:y:xs) = y - x : subs (tail p)
subs (x:xs) = subs xs


showGroup :: Result -> String -> IO ()
showGroup :: Result -> String -> IO ()