Partition an integer x into n primes: Difference between revisions

m
→‎{{header|Haskell}}: (minor reductions – fractionally faster)
m (→‎{{header|Haskell}}: Specified one import)
m (→‎{{header|Haskell}}: (minor reductions – fractionally faster))
Line 624:
[ x
| x `elem` ps_ ]
go ps_ x n = ((flip bool [] . head) <*> null) (foldMap found ps_)
let found = foldMap partitionsFound ps_
in bool (head found) [] (null found)
where
partitionsFoundfound p =
let((flip rbool =[] x. -return . (p :)) <*> null)
rs((go =<< go (delete p (. flip takeWhile ps_ . (<>= r) ps_)) r (nx - 1p) (pred n))
in bool [p : rs] [] (null rs)
 
-------------------------- TEST ---------------------------
9,659

edits