Display an outline as a nested table: Difference between revisions
Display an outline as a nested table (view source)
Revision as of 18:08, 6 September 2021
, 2 years ago→Python: Functional: On slight simplification by generalisation
(→{{header|JavaScript}}: Added spacing between successive tables, if any, for forest case) |
m (→Python: Functional: On slight simplification by generalisation) |
||
Line 2,467:
paintedTree(colorSwatch),
widthMeasuredTree,
)
Line 2,542:
# -------------- TREE PADDED TO EVEN DEPTH ---------------
'''▼
return paddedTree("")(▼
# paddedTree :: a -> (Int, Node a) -> Node a
Line 2,560 ⟶ 2,549:
where needed.
'''
def go(
tree.get('nest') or [Node(padValue)([])]
]) if prev else tree
return pad
return go
Line 2,707 ⟶ 2,698:
# ----------------------- GENERIC ------------------------
# ap :: (a -> b -> c) -> (a -> b) -> a -> c
def ap(f):
'''Applicative instance for functions.
▲ '''
def go(g):
return lambda x: f(x)(g(x))
# compose :: ((a -> a), ...) -> (a -> a)
def compose(*fs):
'''Composition, from right to left,
|