diff options
author | Nao Pross <np@0hm.ch> | 2023-10-17 16:08:53 +0200 |
---|---|---|
committer | Nao Pross <np@0hm.ch> | 2023-10-17 19:38:00 +0200 |
commit | 56cd8e7a5bf1cb583af728e8b4f04ddf3742a1dd (patch) | |
tree | 706ac2fe5a0a3eeb4783c4517dff9c30b5a497fe /src/act4e_solutions/maps.py | |
parent | Sketch TestFiniteMapRepresentation (diff) | |
download | act4e-56cd8e7a5bf1cb583af728e8b4f04ddf3742a1dd.tar.gz act4e-56cd8e7a5bf1cb583af728e8b4f04ddf3742a1dd.zip |
Pass TestFiniteMapRepresentation and TestFiniteMapOperations
Diffstat (limited to 'src/act4e_solutions/maps.py')
-rw-r--r-- | src/act4e_solutions/maps.py | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/act4e_solutions/maps.py b/src/act4e_solutions/maps.py index aff881f..f056da8 100644 --- a/src/act4e_solutions/maps.py +++ b/src/act4e_solutions/maps.py @@ -1,6 +1,7 @@ from typing import TypeVar import act4e_interfaces as I +from .maps_representation import MyFiniteMap A = TypeVar("A") B = TypeVar("B") @@ -10,7 +11,16 @@ C = TypeVar("C") class SolFiniteMapOperations(I.FiniteMapOperations): def identity(self, s: I.Setoid[A]) -> I.Mapping[A, A]: - raise NotImplementedError() + values = [] + for a in s.elements(): + values.append([a, a]) + + return MyFiniteMap(s, s, values) + def compose(self, f: I.FiniteMap[A, B], g: I.FiniteMap[B, C]) -> I.FiniteMap[A, C]: - raise NotImplementedError() + values = [] + for a in f.source().elements(): + values.append([a, g(f(a))]) + + return MyFiniteMap(f.source(), g.target(), values) |