turing-py 2.1.0__tar.gz → 2.2.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {turing_py-2.1.0 → turing_py-2.2.0}/PKG-INFO +1 -1
- {turing_py-2.1.0 → turing_py-2.2.0}/pyproject.toml +1 -1
- {turing_py-2.1.0 → turing_py-2.2.0}/src/tmpy/machine/machine.py +1 -0
- {turing_py-2.1.0 → turing_py-2.2.0}/src/tmpy/transition/transition_function.py +10 -12
- {turing_py-2.1.0 → turing_py-2.2.0}/LICENSE +0 -0
- {turing_py-2.1.0 → turing_py-2.2.0}/README.md +0 -0
- {turing_py-2.1.0 → turing_py-2.2.0}/src/tmpy/__init__.py +0 -0
- {turing_py-2.1.0 → turing_py-2.2.0}/src/tmpy/alphabet/__init__.py +0 -0
- {turing_py-2.1.0 → turing_py-2.2.0}/src/tmpy/alphabet/input_alphabet.py +0 -0
- {turing_py-2.1.0 → turing_py-2.2.0}/src/tmpy/alphabet/symbol.py +0 -0
- {turing_py-2.1.0 → turing_py-2.2.0}/src/tmpy/alphabet/tape_alphabet.py +0 -0
- {turing_py-2.1.0 → turing_py-2.2.0}/src/tmpy/dsl/__init__.py +0 -0
- {turing_py-2.1.0 → turing_py-2.2.0}/src/tmpy/dsl/ast.py +0 -0
- {turing_py-2.1.0 → turing_py-2.2.0}/src/tmpy/dsl/lexer.py +0 -0
- {turing_py-2.1.0 → turing_py-2.2.0}/src/tmpy/dsl/loader.py +0 -0
- {turing_py-2.1.0 → turing_py-2.2.0}/src/tmpy/dsl/parser.py +0 -0
- {turing_py-2.1.0 → turing_py-2.2.0}/src/tmpy/dsl/token.py +0 -0
- {turing_py-2.1.0 → turing_py-2.2.0}/src/tmpy/exception.py +0 -0
- {turing_py-2.1.0 → turing_py-2.2.0}/src/tmpy/machine/__init__.py +0 -0
- {turing_py-2.1.0 → turing_py-2.2.0}/src/tmpy/machine/states.py +0 -0
- {turing_py-2.1.0 → turing_py-2.2.0}/src/tmpy/machine/tape.py +0 -0
- {turing_py-2.1.0 → turing_py-2.2.0}/src/tmpy/transition/__init__.py +0 -0
- {turing_py-2.1.0 → turing_py-2.2.0}/src/tmpy/transition/direction.py +0 -0
- {turing_py-2.1.0 → turing_py-2.2.0}/src/tmpy/transition/transition.py +0 -0
|
@@ -13,25 +13,23 @@ from .transition import Transition
|
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
class TransitionFunction:
|
|
16
|
-
def __init__(self) -> None:
|
|
17
|
-
self._transitions: dict[tuple[str, Symbol], Transition] = {}
|
|
16
|
+
def __init__(self, *args: Transition) -> None:
|
|
18
17
|
|
|
19
|
-
|
|
18
|
+
self._tr: dict[tuple[str, Symbol], Transition] = {}
|
|
20
19
|
|
|
21
|
-
for t in
|
|
20
|
+
for t in args:
|
|
22
21
|
|
|
23
22
|
if isinstance(t, Iterable) and not isinstance(t, Transition):
|
|
24
23
|
for tr in t:
|
|
25
|
-
self.
|
|
24
|
+
self._tr[(tr.state, tr.symbol)] = tr
|
|
26
25
|
else:
|
|
27
|
-
self.
|
|
26
|
+
self._tr[(t.state, t.symbol)] = t
|
|
28
27
|
|
|
29
28
|
def __call__(self, state: str, symbol: Symbol) -> Transition | None:
|
|
30
|
-
return self.
|
|
29
|
+
return self._tr.get((state, symbol))
|
|
31
30
|
|
|
32
|
-
def
|
|
33
|
-
return
|
|
31
|
+
def __contains__(self, item) -> bool:
|
|
32
|
+
return item in self._tr
|
|
34
33
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
return self._transitions
|
|
34
|
+
def __str__(self) -> str:
|
|
35
|
+
return "\n".join(str(t) for t in self._tr.values())
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|