Add UE5 A.2

This commit is contained in:
Ivaylo Ivanov 2021-11-18 17:05:21 +01:00
parent e740c1b38b
commit 7033fc1258

View File

@ -97,6 +97,11 @@ instance Num Zahlraum_0_10 where
(-) n n' = diff_r n n' (-) n n' = diff_r n n'
(*) n n' = mult_r n n' (*) n n' = mult_r n n'
fromInteger n = nat_to_roman (fromInteger n) fromInteger n = nat_to_roman (fromInteger n)
abs n = n
signum n
| n == F = F
| n == N = N
| otherwise = I
add_r :: Zahlraum_0_10 -> Zahlraum_0_10 -> Zahlraum_0_10 add_r :: Zahlraum_0_10 -> Zahlraum_0_10 -> Zahlraum_0_10
add_r n n' add_r n n'
@ -127,12 +132,22 @@ mult_r n n'
-- Aufgabe A.2 -- Aufgabe A.2
-- instance Eq Funktion where instance Eq Funktion where
-- ... (==) f f' = (show f) == (show f')
-- instance Show Funktion where instance Show Funktion where
-- ... show f =
let
result = drop 1 (show (build_pairs f N))
in
"{" ++ take ((length result) -1) result ++ "}"
build_pairs :: Funktion -> Zahlraum_0_10 -> [(Zahlraum_0_10, Zahlraum_0_10)]
build_pairs fkt arg
| arg == F && z == F = [(F, F)]
| otherwise = (arg, z) : (build_pairs fkt (arg + I))
where
z = (f fkt) arg
-- Aufgabe A.3 -- Aufgabe A.3