Partition an integer x into n primes: Difference between revisions
Content added Content deleted
m (→{{header|Haskell}}: Specified one import) |
m (→{{header|Haskell}}: (minor reductions – fractionally faster)) |
||
Line 624: | Line 624: | ||
[ x |
[ x |
||
| x `elem` ps_ ] |
| x `elem` ps_ ] |
||
go ps_ x n = |
go ps_ x n = ((flip bool [] . head) <*> null) (foldMap found ps_) |
||
let found = foldMap partitionsFound ps_ |
|||
in bool (head found) [] (null found) |
|||
where |
where |
||
found p = |
|||
((flip bool [] . return . (p :)) <*> null) |
|||
((go =<< delete p . flip takeWhile ps_ . (>=)) (x - p) (pred n)) |
|||
in bool [p : rs] [] (null rs) |
|||
-------------------------- TEST --------------------------- |
-------------------------- TEST --------------------------- |