splitends.splitend_node¶
Data node class used privately by class SplitEnd.
Node classes used to make bush-like graphs. API made public since it
might prove useful to someone designing other data structures similar
to a splitend
.
- class pythonic_fp.splitends.splitend_node.SENode(data: D, prev: SENode[D] | None = None)¶
Data node for class SplitEnd
hashable data node for a end-to-root singularly linked list.
designed so multiple splitends can safely share the same data
two nodes compare as equal if
both their previous Nodes are the same
their data compare as equal
more than one node can point to the same proceeding node
forming bush like graphs
- Parameters:
data – nodes always contain data of type D
prev – potential link to a previous node
- fold(f: Callable[[T, D], T], init: T | None = None) T ¶
Fold data across linked nodes with a function..
def fold[T]( self, f: Callable([T, D], T], init: T | None = None ) -> T
- Parameters:
f – folding function, first argument is for accumulated value
init – optional initial starting value for the fold
- Returns:
reduced value folding from end to root in natural LIFO order
- peak() D ¶
Return contained data