Improve code prettiness
This commit is contained in:
parent
ca934d2391
commit
29df3d710a
@ -6,7 +6,7 @@ filter :: (a -> Bool) -> [a] -> [a]
|
|||||||
\pause
|
\pause
|
||||||
\begin{haskellcode}
|
\begin{haskellcode}
|
||||||
filter :: (a -> Bool) -> [a] -> [a]
|
filter :: (a -> Bool) -> [a] -> [a]
|
||||||
filter f [] = []
|
filter f [] = []
|
||||||
filter f (x:xs)
|
filter f (x:xs)
|
||||||
| f x = x : filter f xs
|
| f x = x : filter f xs
|
||||||
| otherwise = filter f xs
|
| otherwise = filter f xs
|
||||||
|
@ -6,20 +6,20 @@ sum :: [Int] -> Int
|
|||||||
\pause
|
\pause
|
||||||
\begin{haskellcode}
|
\begin{haskellcode}
|
||||||
sum :: [Int] -> Int
|
sum :: [Int] -> Int
|
||||||
sum [] = 0
|
sum [] = 0
|
||||||
sum (x:xs) = x + sum xs
|
sum (x:xs) = x + sum xs
|
||||||
\end{haskellcode}
|
\end{haskellcode}
|
||||||
\pause
|
\pause
|
||||||
\ifger{Oder das Produkt:}{Or the product:}
|
\ifger{Oder das Produkt:}{Or the product:}
|
||||||
\begin{haskellcode}
|
\begin{haskellcode}
|
||||||
prod :: [Int] -> Int
|
prod :: [Int] -> Int
|
||||||
prod [] = 1
|
prod [] = 1
|
||||||
prod (x:xs) = x * prod xs
|
prod (x:xs) = x * prod xs
|
||||||
\end{haskellcode}
|
\end{haskellcode}
|
||||||
\pause
|
\pause
|
||||||
\ifger{Oder die Länge:}{Or the length:}
|
\ifger{Oder die Länge:}{Or the length:}
|
||||||
\begin{haskellcode}
|
\begin{haskellcode}
|
||||||
length :: [a] -> Int
|
length :: [a] -> Int
|
||||||
length [] = 0
|
length [] = 0
|
||||||
length (x:xs) = 1 + length xs
|
length (x:xs) = 1 + length xs
|
||||||
\end{haskellcode}
|
\end{haskellcode}
|
@ -1,7 +1,7 @@
|
|||||||
\ifger{Lösung:}{Solution:}
|
\ifger{Lösung:}{Solution:}
|
||||||
\begin{haskellcode}
|
\begin{haskellcode}
|
||||||
addTwo :: [Int] -> [Int]
|
addTwo :: [Int] -> [Int]
|
||||||
addTwo [] = []
|
addTwo [] = []
|
||||||
addTwo (x:xs) = (x + 2) : addTwo xs
|
addTwo (x:xs) = (x + 2) : addTwo xs
|
||||||
\end{haskellcode}
|
\end{haskellcode}
|
||||||
\pause
|
\pause
|
||||||
@ -9,14 +9,14 @@ addTwo (x:xs) = (x + 2) : addTwo xs
|
|||||||
\pause
|
\pause
|
||||||
\begin{haskellcode}
|
\begin{haskellcode}
|
||||||
square :: [Int] -> [Int]
|
square :: [Int] -> [Int]
|
||||||
square [] = []
|
square [] = []
|
||||||
square (x:xs) = (x * x) : square xs
|
square (x:xs) = (x * x) : square xs
|
||||||
\end{haskellcode}
|
\end{haskellcode}
|
||||||
\pause
|
\pause
|
||||||
\ifger{Jetzt wollen wir den Betrag jedes Elements:}{Now we want the absolute of every element:}
|
\ifger{Jetzt wollen wir den Betrag jedes Elements:}{Now we want the absolute of every element:}
|
||||||
\begin{haskellcode}
|
\begin{haskellcode}
|
||||||
absList :: [Int] -> [Int]
|
absList :: [Int] -> [Int]
|
||||||
absList [] = []
|
absList [] = []
|
||||||
absList (x:xs) = (abs x) : absList xs
|
absList (x:xs) = (abs x) : absList xs
|
||||||
\end{haskellcode}
|
\end{haskellcode}
|
||||||
\pause
|
\pause
|
||||||
|
Loading…
Reference in New Issue
Block a user