From 56cd8e7a5bf1cb583af728e8b4f04ddf3742a1dd Mon Sep 17 00:00:00 2001 From: Nao Pross Date: Tue, 17 Oct 2023 16:08:53 +0200 Subject: Pass TestFiniteMapRepresentation and TestFiniteMapOperations --- src/act4e_solutions/maps.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'src/act4e_solutions/maps.py') 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) -- cgit v1.2.1