Add UE3 A.2
This commit is contained in:
parent
953219e8fc
commit
09b8148fa6
@ -38,12 +38,28 @@ Solution:
|
|||||||
|
|
||||||
Aufgabe A.2
|
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
|
Aufgabe A.3
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user