summaryrefslogtreecommitdiffstats
path: root/src/act4e_solutions/maps.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/act4e_solutions/maps.py')
-rw-r--r--src/act4e_solutions/maps.py14
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)