diff --git a/code/Angabe3.lhs b/code/Angabe3.lhs index 25fb941..cc6c6f2 100644 --- a/code/Angabe3.lhs +++ b/code/Angabe3.lhs @@ -38,12 +38,28 @@ Solution: Aufgabe A.2 -Knapp, aber gut nachvollziehbar geht matrixtyp folgendermassen vor: -... +Solution: + * if the parameter is an empty matrix, then return KeineMatrix + * check if the parameter is an NM matrix by obtaining the length of the first row and comparing it with each consequitive one. If there is a mismatch, then the matrix is not a NM matrix + * if the parameter is an NM matrix, return the pair (height, width) -matrixtyp :: Matrix -> Matrixtyp - ... +> matrixtyp :: Matrix -> Matrixtyp +> matrixtyp m +> | m == fehlerwert = KeineMatrix +> | isCorrectMatrix m 0 == False = KeineMatrix +> | otherwise = getMatrixType m +> isCorrectMatrix :: Matrix -> Int -> Bool +> isCorrectMatrix matrix n +> | matrix == fehlerwert = True +> | n == 0 && length m /= 0 = isCorrectMatrix matrix (length m) +> | n == length m = isCorrectMatrix (M ms) n +> | otherwise = False +> where +> (M (m:ms)) = matrix + +> getMatrixType :: Matrix -> Matrixtyp +> getMatrixType (M (m:ms)) = (Mat (length (m:ms), length m)) Aufgabe A.3