Visualize a tree: Difference between revisions

m
→‎Functional Python: Small edits to a couple of primitives
m (→‎Functional composition: (edited a comment line))
m (→‎Functional Python: Small edits to a couple of primitives)
Line 2,202:
)
 
def lmrBuild(fw, wf):
def go(wsTree):
nChars, x = wsTree['root']
Line 2,382:
def go(x):
return Node(f(x['root']))(
list(map([go,(v) for v in x['nest']))]
)
return lambda tree: go(tree)
Line 2,391:
'''Right to left reduction of a list,
using the binary operator f, and
starting with an initial valueaccumulator avalue.
'''
def g(x, a):
return f(a, x)
return lambda acc: lambda xs: reduce(
fg, xs[::-1], acc
)
 
9,655

edits