Display an outline as a nested table: Difference between revisions
Content added Content deleted
(→Python: Functional: Adjusted to allow for outlines with more than one root (forests, rather than trees)) |
(→{{header|Haskell}}: Updated to allow for writing several tables, where outline has several top-level roots) |
||
Line 513: | Line 513: | ||
import Data.Tree (Tree (..), foldTree, levels) |
import Data.Tree (Tree (..), foldTree, levels) |
||
---------------- NESTED |
---------------- NESTED TABLES FROM OUTLINE -------------- |
||
wikiTablesFromOutline :: [String] -> String -> String |
|||
wikiTablesFromOutline colorSwatch outline = |
|||
intercalate "\n\n" $ |
|||
wikiTableFromTree colorSwatch |
|||
⚫ | |||
⚫ | |||
⚫ | |||
) |
|||
outline |
|||
wikiTableFromTree :: [String] -> Tree String -> String |
|||
wikiTableFromTree colorSwatch = |
|||
wikiTableFromRows |
wikiTableFromRows |
||
. levels |
. levels |
||
Line 522: | Line 532: | ||
. widthLabelledTree |
. widthLabelledTree |
||
. (paddedTree [] =<< treeDepth) |
. (paddedTree [] =<< treeDepth) |
||
. head -- Just the first tree of any forest |
|||
⚫ | |||
⚫ | |||
⚫ | |||
--------------------------- TEST ------------------------- |
--------------------------- TEST ------------------------- |
||
Line 531: | Line 537: | ||
main = |
main = |
||
( putStrLn |
( putStrLn |
||
. |
. wikiTablesFromOutline |
||
[ "#ffffe6", |
[ "#ffffe6", |
||
"#ffebd2", |
"#ffebd2", |