Jump to content

Display an outline as a nested table: Difference between revisions

→‎{{header|Haskell}}: Updated to allow for writing several tables, where outline has several top-level roots
(→‎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:
import Data.Tree (Tree (..), foldTree, levels)
 
---------------- NESTED TABLETABLES FROM OUTLINE ---------------
 
wikiTableFromOutlinewikiTablesFromOutline :: [String] -> String -> String
wikiTableFromOutlinewikiTablesFromOutline colorSwatch outline =
intercalate "\n\n" $
wikiTableFromTree colorSwatch
. <$> ( forestFromLineIndents
. indentLevelsFromLines
. lines
)
outline
 
wikiTableFromTree :: [String] -> Tree String -> String
wikiTableFromTree colorSwatch =
wikiTableFromRows
. levels
Line 522 ⟶ 532:
. widthLabelledTree
. (paddedTree [] =<< treeDepth)
. head -- Just the first tree of any forest
. forestFromLineIndents
. indentLevelsFromLines
. lines
 
--------------------------- TEST -------------------------
Line 531 ⟶ 537:
main =
( putStrLn
. wikiTableFromOutlinewikiTablesFromOutline
[ "#ffffe6",
"#ffebd2",
9,659

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.