Partition an integer x into n primes: Difference between revisions

Content added Content deleted
m (→‎{{header|Haskell}}: (minor reductions – fractionally faster))
Line 613: Line 613:


-------------------- PRIME PARTITIONS ---------------------
-------------------- PRIME PARTITIONS ---------------------
partition :: Int -> Int -> [Int]
partitions :: Int -> Int -> [Int]
partition x n
partitions x n
| n <= 1 =
| n <= 1 =
[ x
[ x
Line 638: Line 638:
" -> "
" -> "
[ justifyLeft 9 ' ' (show (x, n))
[ justifyLeft 9 ' ' (show (x, n))
, let xs = partition x n
, let xs = partitions x n
in bool (intercalate "+" (show <$> xs)) "(no solution)" (null xs)
in bool (intercalate "+" (show <$> xs)) "(no solution)" (null xs)
]) <$>
]) <$>