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