diff --git a/code/Angabe6.hs b/code/Angabe6.hs index fa7e2f1..31eb406 100644 --- a/code/Angabe6.hs +++ b/code/Angabe6.hs @@ -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