Subato

Resource Files

Standardlisten

In dieser Aufgabe beschäftigen wir uns mit den Standarlisten in Haskell.


> module Listen where > import Data.List > import Data.Ratio > data Li a = E | a :> Li a deriving (Show,Eq) > infixr 5 :> > laengeLi E = 0 > laengeLi (_:>xs) = 1 + laengeLi xs > laenge [] = 0 > laenge (_:xs) = 1 + laenge xs > letzteLi (x:>E) = x > letzteLi (_:>xs) = letzteLi xs > letzte1 (x:[]) = x > letzte1 (_:xs) = letzte1 xs > letzte2 [x] = x > letzte2 (_:xs) = letzte2 xs > istSortiertLi (x1:>x2:>xs) > |x1<=x2 = istSortiertLi (x2:>xs) > |otherwise = False > istSortiertLi _ = True > istSortiert (x1:x2:xs) > |x1<=x2 = istSortiert (x2:xs) > |otherwise = False > istSortiert _ = True > istSortiert2 (x1:ys@(x2:xs)) > |x1<=x2 = istSortiert2 ys > |otherwise = False > istSortiert2 _ = True > wiederholeLi x = x:>wiederholeLi x > wiederhole x = x:wiederhole x > factorial1 n = product [1,2..n] > factorial2 n = product$take n [1,2..] > isPalindrome :: Eq a => [a] -> Bool > isPalindrome xs = False > everyNth :: Integral a => a -> [b] -> [b] > everyNth _ _ = [] > swapNeighbours :: [a] -> [a] > swapNeighbours xs = xs > maxRep :: Eq a => [a] -> Int > maxRep _ = 0 > leibniz:: [Rational] > leibniz = [k {-- ToDo --}|k<-[0,1..]] > fatio:: [Rational] > fatio = [k {-- ToDo --}|k<-[0,1..]] > squaresum :: (Foldable t, Num a, Functor t) => t a -> a > squaresum xs = 0 > sqx :: (Fractional a, Foldable t, Functor t) => t a -> a > sqx xs = 0 -- Todo > where > l x = fromIntegral $ length x > mittelwerte :: (Fractional a, Enum a) => [a] -> [a] > mittelwerte xs = [] --ToDo > readBinary:: String -> Integer > readBinary xs = aux 0 xs > where > aux result xs = result > toOctalString :: (Show a, Integral a) => a -> String > toOctalString x = "" > occurrences :: (Num a, Eq t) => [t] -> [(a, t)] > occurrences _ = [] --ToDo > anagram :: Eq a => [a] -> [[a]] > anagram xs = [] --ToDo
lhs