Add UE6 A2 and A4 implementations
This commit is contained in:
parent
0b837f76cf
commit
b5eef0023e
@ -45,6 +45,7 @@ construct_row f numcol rc cc res
|
||||
|
||||
is_correct_matrix :: MatrixF -> Bool
|
||||
is_correct_matrix m
|
||||
| height == 0 || width == 0 = False
|
||||
| fst t == height && snd t == width = True
|
||||
| otherwise = False
|
||||
where
|
||||
@ -75,17 +76,22 @@ matrix_to_string matrix res
|
||||
|
||||
matrixtyp :: MatrixF -> Maybe Matrixtyp
|
||||
matrixtyp (Mf t f)
|
||||
| is_correct_matrix (Mf t f) == False = Nothing
|
||||
| otherwise = (Just (0,0))
|
||||
| not(is_correct_matrix (Mf t f)) = Nothing
|
||||
| otherwise = (Just (height, width))
|
||||
where
|
||||
mtx = construct_matrix (Mf t f) 1 []
|
||||
height = length mtx
|
||||
width = length (head mtx)
|
||||
|
||||
-- Aufgabe A.4
|
||||
|
||||
instance Eq MatrixF where
|
||||
(Mf t1 f1) == (Mf t2 f2)
|
||||
| is_correct_matrix (Mf t1 f1) == False || is_correct_matrix (Mf t2 f2) = error "Gleichheit undefiniert"
|
||||
| otherwise =
|
||||
if show (Mf t1 f1) == show (Mf t2 f2) then True
|
||||
else False
|
||||
| not(is_correct_matrix (Mf t1 f1)) || not(is_correct_matrix (Mf t2 f2)) = error "Gleichheit undefiniert"
|
||||
| otherwise = show (Mf t1 f1) == show (Mf t2 f2)
|
||||
(Mf t1 f1) /= (Mf t2 f2)
|
||||
| not(is_correct_matrix (Mf t1 f1)) || not(is_correct_matrix (Mf t2 f2)) = error "Ungleichheit undefiniert"
|
||||
| otherwise = show (Mf t1 f1) /= show (Mf t2 f2)
|
||||
|
||||
-- Aufgabe A.5
|
||||
|
||||
|
Reference in New Issue
Block a user