tierkreis.graphs.fold

Preconstructed graph for folding operations.

Module Contents

Classes

FoldGraphInputs

Inputs to a fold graph.

FoldFunctionInput

Input type of a fold function.

Functions

fold_graph

Construct a fold graph.

Data

API

A_co = 'TypeVar(...)'
B_co = 'TypeVar(...)'
class FoldGraphInputs

Bases: typing.NamedTuple

Inputs to a fold graph.

Fields:

initial (B): The initial value. values (list[A]): The list of values to fold over.

initial: tierkreis.controller.data.models.TKR[tierkreis.graphs.fold.FoldGraphInputs.B] = None
values: tierkreis.controller.data.models.TKR[list[tierkreis.graphs.fold.FoldGraphInputs.A]] = None
class FoldFunctionInput

Bases: typing.NamedTuple

Input type of a fold function.

Fields:

accum (B): The accumulator. value (A): The current value.

accum: tierkreis.controller.data.models.TKR[tierkreis.graphs.fold.FoldFunctionInput.B] = None
value: tierkreis.controller.data.models.TKR[tierkreis.graphs.fold.FoldFunctionInput.A] = None
fold_graph(func: tierkreis.builder.Workflow[tierkreis.graphs.fold.FoldFunctionInput[tierkreis.graphs.fold.fold_graph.A_co, tierkreis.graphs.fold.fold_graph.B_co], tierkreis.controller.data.models.TKR[tierkreis.graphs.fold.fold_graph.B_co]]) tierkreis.builder.Workflow[tierkreis.graphs.fold.FoldGraphInputs[tierkreis.graphs.fold.fold_graph.A_co, tierkreis.graphs.fold.fold_graph.B_co], tierkreis.controller.data.models.TKR[tierkreis.graphs.fold.fold_graph.B_co]]

Construct a fold graph.

fold : {func: (b -> a -> b)} -> {initial: b} -> {values: list[a]} -> {value: b} fold : { A x B -> B } -> { list[A] x B -> B }

Parameters:

func (Graph[FoldFunctionInput[A_co, B_co], TKR[B_co]]) – The function to fold over.

Returns:

A graph implementing the fold function.

Return type:

Graph[FoldGraphInputs[A_co, B_co], TKR[B_co]]