cognition.decision.chain¶
Support for a decision process generated via an iterable value.
Classes¶
A link in a chained decision process |
|
State of a chained decision process |
Functions¶
|
Decision process via an iterable that with a handler at each value accumulating a result |
Module Contents¶
- class cognition.decision.chain.Link[CV, CA]¶
A link in a chained decision process
- value: CV¶
current iterated value
- accumulator: CA | None¶
current (optional) user-accumulated value
- class cognition.decision.chain.ChainState[CV, CA](chain, init_acc=None)¶
State of a chained decision process
Parameters represent…
CV: type of iterated (v)aluesCA: type of an optional (a)ccumulator
- Parameters:
chain (collections.abc.Iterable[CV]) – something iterable
init_acc (CA | None) – (optional) initial accumulator value
- __str__()¶
- Return type:
str
- property done: bool¶
- Returns:
Trueif the iterable (chain) has been exhausted- Return type:
bool
- property current_link: Link[CV, CA] | None¶
- Returns:
current link in the chain, or
Noneif exhausted- Return type:
Link[CV, CA] | None
- property accumulator: CA | None¶
- Returns:
current accumulator value
- Return type:
CA | None
- next(acc)¶
Proceeds with the chain
- Parameters:
acc (CA | None) – optional new accumulator value
- Return type:
None
- cognition.decision.chain.create_chain_dp[CV, CA](chain, link_handler, init_accumulator=None)¶
Decision process via an iterable that with a handler at each value accumulating a result
- Parameters:
chain (collections.abc.Iterable[CV]) – sequence of values
link_handler (cognition.util.functypes.BiFunction[Link[CV, CA], cognition.decision.core.IOContainer, CA | None]) – function called at each chain link that can update the accumulator
init_accumulator (CA | None) – initial (optional) accumulator value
- Returns:
produced decision process
- Return type: