Numbers with prime digits whose sum is 13: Difference between revisions
Numbers with prime digits whose sum is 13 (view source)
Revision as of 18:49, 21 October 2020
, 3 years ago→{{header|Haskell}}: Slightly reduced one expression.
(→{{header|Haskell}}: As an unfold, in the pattern of Nigel Galloway's recursion.) |
m (→{{header|Haskell}}: Slightly reduced one expression.) |
||
Line 188:
where
primeDigits = [2, 3, 5, 7]
step xs =▼
let nvs =▼
fmap ((,) <*> sum) ((<$> xs) . flip (<>) . return =<< primeDigits)▼
in ( nvs >>=▼
(\nv ->▼
[ unDigits $ fst nv▼
| 13 == snd nv ])▼
, nvs >>=▼
go xs
| null xs = Nothing
| otherwise = Just (step xs)
▲ step xs =
in ((,) . (>>= f) <*> (>>= g))
unDigits :: [Int] -> Int
|