List rooted trees: Difference between revisions
Content added Content deleted
m (→{{header|Haskell}}: Simplified the Data.Tree version a little) |
m (→{{header|Haskell}}: Named a couple of anonymous functions) |
||
Line 571: | Line 571: | ||
bagPatterns n = |
bagPatterns n = |
||
nub $ |
nub $ |
||
foldTree |
foldTree asBrackets |
||
⚫ | |||
(\_ xs -> '(' : (concat xs <> ")")) |
|||
⚫ | |||
⚫ | |||
) |
|||
. treeFromParentIndices |
. treeFromParentIndices |
||
<$> parentIndexPermutations n |
<$> parentIndexPermutations n |
||
Line 584: | Line 581: | ||
----------------------- DEFINITIONS ---------------------- |
----------------------- DEFINITIONS ---------------------- |
||
asBrackets :: a -> [String] -> String |
|||
asBrackets = const (('(' :) . (<> ")") . concat) |
|||
depthSorted :: a -> [Tree Int] -> Tree Int |
|||
⚫ | |||
parentIndexPermutations :: Int -> [[Int]] |
parentIndexPermutations :: Int -> [[Int]] |