Improve function composition slides
This commit is contained in:
parent
db59997841
commit
ca0f732f08
9
VL2.tex
9
VL2.tex
@ -366,6 +366,15 @@ Solution:
|
|||||||
(.) :: (b -> c) -> (a -> b) -> a -> c
|
(.) :: (b -> c) -> (a -> b) -> a -> c
|
||||||
(.) f g x = f (g x)
|
(.) f g x = f (g x)
|
||||||
\end{haskellcode}
|
\end{haskellcode}
|
||||||
|
\pause
|
||||||
|
And now you can chain functions together. Not just two! Look:
|
||||||
|
\begin{haskellcode}
|
||||||
|
f :: String -> Bool
|
||||||
|
f xs = (even . length . (\x -> x ++ "Hello world")) xs
|
||||||
|
-- or less ugly
|
||||||
|
f xs = even . length . (\x -> x ++ "Hello world") $ xs
|
||||||
|
\end{haskellcode}
|
||||||
|
% $
|
||||||
\end{frame}
|
\end{frame}
|
||||||
|
|
||||||
\section{6. Recursion patterns}
|
\section{6. Recursion patterns}
|
||||||
|
Loading…
Reference in New Issue
Block a user