creek.automatas#
Automatas (finite state machines): step a state through a stream of symbols.
Main entry points:
mapping_to_transition_func: a transition function from a{(state, symbol): next_state}mappingbasic_automata:basic_automata(transition_func, state)(symbols)yields the state after each symbolBasicAutomata: the same as a stateful, resettable object
>>> from creek.automatas import mapping_to_transition_func, basic_automata
>>> step = mapping_to_transition_func({('a', 1): 'b', ('b', 1): 'a'})
>>> list(basic_automata(step, 'a')([1, 1, 1]))
['b', 'a', 'b']
Functions
|
Make an automata: |
|
Make an automata: |
|
Make a transition function from a |
Classes
|
Stateful automata: |
|
Class form of |
- class creek.automatas.BasicAutomata(transition_func, state=None)[source]#
Bases:
objectStateful automata:
automata(state, symbols)yields the state after each symbol;resetrestores the initial one.
- class creek.automatas.MappingTransitionFunc(mapping, strict=True)[source]#
Bases:
objectClass form of
mapping_to_transition_func: a callable(state, symbol) -> next_state.
- creek.automatas.automata(transition_func, state)#
Make an automata:
basic_automata(f, state)(symbols)yields the state after each symbol.
- creek.automatas.basic_automata(transition_func, state)[source]#
Make an automata:
basic_automata(f, state)(symbols)yields the state after each symbol.