Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Aufgabe 1
- (\\) :: [a]->[a]->[a]
- (\\) b [] = b
- (\\) [] z = []
- (\\) (x:xs) (y:ys)
- | elem x (y:ys) = xs \\(y:ys)
- |otherwise = x: (xs \\ (y:ys))
- (\\) :: [a] -> [a] -> [a]
- (\\) x y = [s | s <- x , not (elem s y) ]
- smallestNatNotIn :: [a]-> a
- smallestNatNotIn x = head ([1..(maximum x)] \\ x)
- -- Da die Funkiom (\\) quadratisch ist, da er mit n(x) elementen n(y) elemente prüft,
- -- hat diese Funktion einen uadratischen Aufwand und somit auch die Funkion smallestNatNotIn ,
- -- da in ihr die Funktion (\\) aufgerufen wird. -> O(n^2)
- --Aufgabe2 Addition fehlt
- data QRational = Q ZInt ZInt deriving Show
- qadd ::
- qmult:: QRational -> QRational -> QRational
- qmult (Q a b) (Q c d) = Q (zmult a c) (zmult b d)
- qquotient :: QRational -> QRational -> QRational
- qquotient (Q a b) (Q c d) = qmult (Q a b ) (qreciprocal Q c d)
- qreciprocal :: QRational -> QRational
- qrecoprocal Q b c
- | zsimplify b == Z Zero Zero = error " division für mit NULL nicht definiert"
- | otherwise = Q c b
- --Aufgabe3
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement