Ormiston pairs: Difference between revisions
Content added Content deleted
(→{{header| Haskell}}: Added a Haskell draft) |
(→{{header|Haskell}}: Fractionally more efficient) |
||
Line 805: | Line 805: | ||
<syntaxhighlight lang=haskell>import Data.List (sort) |
<syntaxhighlight lang=haskell>import Data.List (sort) |
||
import Data.Numbers.Primes (primes) |
import Data.Numbers.Primes (primes) |
||
---------------------- ORMISTON PAIRS -------------------- |
---------------------- ORMISTON PAIRS -------------------- |
||
ormistonPairs :: [(Int, Int)] |
ormistonPairs :: [(Int, Int)] |
||
ormistonPairs = |
ormistonPairs = |
||
[ (fst a, fst b) |
|||
| (a, b) <- zip primeDigits (tail primeDigits), |
|||
snd a == snd b |
|||
sameDigits :: (Int, Int) -> Bool |
|||
] |
|||
sameDigits (a, b) = digits a == digits b |
|||
where |
|||
digits = sort . show |
|||
primeDigits :: [(Int, String)] |
|||
primeDigits = (,) <*> (sort . show) <$> primes |
|||
--------------------------- TEST ------------------------- |
--------------------------- TEST ------------------------- |