Partition an integer x into n primes: Difference between revisions

Content added Content deleted
(Added Rust Solution)
Line 754: Line 754:


=={{header|Haskell}}==
=={{header|Haskell}}==
<lang haskell>import Data.Bool (bool)
<lang haskell>import Data.List (delete, intercalate)
import Data.Numbers.Primes (primes)
import Data.Numbers.Primes (primes)
import Data.List (delete, intercalate)
import Data.Bool (bool)


-------------------- PRIME PARTITIONS ---------------------
-------------------- PRIME PARTITIONS ---------------------
Line 785: Line 785:
[ justifyLeft 9 ' ' (show (x, n))
[ justifyLeft 9 ' ' (show (x, n))
, let xs = partitions x n
, let xs = partitions x n
in bool (intercalate "+" (show <$> xs)) "(no solution)" (null xs)
in bool
(tail $ concatMap (('+' :) . show) xs)
"(no solution)"
(null xs)
]) <$>
]) <$>
concat
concat