23 lines
488 B
TeX
23 lines
488 B
TeX
|
Solution?
|
||
|
\begin{haskellcode}
|
||
|
addTwo :: [Int] -> [Int]
|
||
|
addTwo [] = []
|
||
|
addTwo (x:xs) = (x + 2) : addTwo xs
|
||
|
\end{haskellcode}
|
||
|
\pause
|
||
|
Now we want to square every element:
|
||
|
\pause
|
||
|
\begin{haskellcode}
|
||
|
square :: [Int] -> [Int]
|
||
|
square [] = []
|
||
|
square (x:xs) = (x * x) : square xs
|
||
|
\end{haskellcode}
|
||
|
\pause
|
||
|
Now we want the absolute of every element:
|
||
|
\begin{haskellcode}
|
||
|
absList :: [Int] -> [Int]
|
||
|
absList [] = []
|
||
|
absList (x:xs) = (abs x) : absList xs
|
||
|
\end{haskellcode}
|
||
|
\pause
|
||
|
Do you notice something?
|