Small fixes:
* (README) fixed fuckup with anchor * (wtfunctional.tex) Added shellesc to fix TeXLive2016-issue * (wtfunctional.tex) specified aspect ratio explicitly
This commit is contained in:
parent
ea82f969f5
commit
83116099e9
3 changed files with 45 additions and 27 deletions
16
Readme.md
16
Readme.md
|
@ -27,8 +27,8 @@ using functional paradigms.
|
||||||
|
|
||||||
## Files ##
|
## Files ##
|
||||||
|
|
||||||
You may download both [the slides PDF][slides] in handout mode, and a
|
You may download both [the slides PDF][ext-slides] in handout mode, and a
|
||||||
[source archive][examples] of the examples used during the talk.
|
[source archive][ext-examples] of the examples used during the talk.
|
||||||
|
|
||||||
## Structure ##
|
## Structure ##
|
||||||
|
|
||||||
|
@ -70,8 +70,8 @@ following:
|
||||||
again, texlive should be enough), and
|
again, texlive should be enough), and
|
||||||
* the two fonts [Inconsolata G][inconsolata-g] and [Fira Sans][fira] installed,
|
* the two fonts [Inconsolata G][inconsolata-g] and [Fira Sans][fira] installed,
|
||||||
* not to talk of biber with biblatex.
|
* not to talk of biber with biblatex.
|
||||||
|
|
||||||
Then, compile using
|
Then, compile using
|
||||||
|
|
||||||
```
|
```
|
||||||
lualatex -shell-escape wtfunctional
|
lualatex -shell-escape wtfunctional
|
||||||
|
@ -88,13 +88,13 @@ For the haskell-example, use `ghci`, then `:load 01_haskell.hs`. The functions p
|
||||||
* extract (≅ fst)
|
* extract (≅ fst)
|
||||||
* addto
|
* addto
|
||||||
* mfold (≅ foldl)
|
* mfold (≅ foldl)
|
||||||
|
|
||||||
02_python.py can be executed using `python`, or inspected using `python -m`. It
|
02_python.py can be executed using `python`, or inspected using `python -m`. It
|
||||||
provides:
|
provides:
|
||||||
|
|
||||||
* a debug-function usable as decorator
|
* a debug-function usable as decorator
|
||||||
* a bubblesort-implementation using functional paradigms.
|
* a bubblesort-implementation using functional paradigms.
|
||||||
|
|
||||||
03_cpp.cpp needs a compiler capable of C++11. It shows code- and
|
03_cpp.cpp needs a compiler capable of C++11. It shows code- and
|
||||||
runtime-examples for `for_each`, `transform` and `accumulate`.
|
runtime-examples for `for_each`, `transform` and `accumulate`.
|
||||||
|
|
||||||
|
@ -105,7 +105,7 @@ do. Then compile using the option `std=c++1z`
|
||||||
|
|
||||||
This is licensed under MIT-License. For the exact formulation, see License.txt.
|
This is licensed under MIT-License. For the exact formulation, see License.txt.
|
||||||
|
|
||||||
[examples]: https://www.pheerai.de/assets/wtf_examples.tar.gz
|
[ext-examples]: https://www.pheerai.de/assets/wtf_examples.tar.gz
|
||||||
[f3l]: https://www.f3l.de
|
[f3l]: https://www.f3l.de
|
||||||
[f3lgit]: https://git.f3l.de/pheerai/wtfunctional
|
[f3lgit]: https://git.f3l.de/pheerai/wtfunctional
|
||||||
[fira]: https://github.com/mozilla/Fira
|
[fira]: https://github.com/mozilla/Fira
|
||||||
|
@ -116,7 +116,7 @@ This is licensed under MIT-License. For the exact formulation, see License.txt.
|
||||||
[minted]: http://github.com/gpoore/minted
|
[minted]: http://github.com/gpoore/minted
|
||||||
[pygments]: http://pygments.org/
|
[pygments]: http://pygments.org/
|
||||||
[python]: https://python.org/
|
[python]: https://python.org/
|
||||||
[slides]: https://www.pheerai.de/assets/wtf_slides.pdf
|
[ext-slides]: https://www.pheerai.de/assets/wtf_slides.pdf
|
||||||
[texlive]: https://www.tug.org/texlive/
|
[texlive]: https://www.tug.org/texlive/
|
||||||
[wtfoff]: https://www.pheerai.de/wtf/
|
[wtfoff]: https://www.pheerai.de/wtf/
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,8 @@
|
||||||
\usepackage{upquote}
|
\usepackage{upquote}
|
||||||
\usepackage[section, cache=true,]{minted}
|
\usepackage[section, cache=true,]{minted}
|
||||||
|
|
||||||
|
\renewcommand{\MintedPygmentize}{/usr/bin/pygmentize}
|
||||||
|
|
||||||
\usemintedstyle{manni}
|
\usemintedstyle{manni}
|
||||||
|
|
||||||
\newminted[ccode]{c}%
|
\newminted[ccode]{c}%
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
\documentclass[english]{beamer}
|
\documentclass[english,aspectratio=43]{beamer}
|
||||||
|
|
||||||
\usepackage{babel}
|
\usepackage{babel}
|
||||||
\usepackage{csquotes}
|
\usepackage{csquotes}
|
||||||
\usepackage{tabularx}
|
\usepackage{tabularx}
|
||||||
|
\usepackage{shellesc}
|
||||||
\usepackage[backend=biber,]{biblatex}
|
\usepackage[backend=biber,]{biblatex}
|
||||||
\bibliography{wtf}
|
\bibliography{wtf}
|
||||||
\renewcommand{\bibfont}{\small}
|
\renewcommand{\bibfont}{\small}
|
||||||
|
@ -18,7 +19,8 @@
|
||||||
|
|
||||||
\title{WTFunctional}
|
\title{WTFunctional}
|
||||||
\author{Oliver Rümpelein}
|
\author{Oliver Rümpelein}
|
||||||
\subtitle{Using functional structures in non-functional languages}
|
\subtitle{Functional paradigms and non-functional languages}
|
||||||
|
\date{2016-06-11}
|
||||||
|
|
||||||
\input{headers/listings}
|
\input{headers/listings}
|
||||||
|
|
||||||
|
@ -39,7 +41,7 @@
|
||||||
\section{Dafunc?}
|
\section{Dafunc?}
|
||||||
\subsection{Functional programming}
|
\subsection{Functional programming}
|
||||||
\begin{frame}{Understanding functional paradigms}
|
\begin{frame}{Understanding functional paradigms}
|
||||||
Here: so called \enquote{purely functional} paradigm.
|
Here: so called \enquote{purely/strict functional} paradigm.
|
||||||
\begin{itemize}
|
\begin{itemize}
|
||||||
\item<+-> Programming without \enquote{side-effects}
|
\item<+-> Programming without \enquote{side-effects}
|
||||||
\begin{itemize}
|
\begin{itemize}
|
||||||
|
@ -67,13 +69,13 @@ int main() {
|
||||||
\end{frame}
|
\end{frame}
|
||||||
|
|
||||||
\begin{frame}{Pros and Cons}
|
\begin{frame}{Pros and Cons}
|
||||||
Pros:
|
\uncover<+->{Pros:}
|
||||||
\begin{itemize}[<+->]
|
\begin{itemize}[<+->]
|
||||||
\item Maintainability
|
\item Maintainability
|
||||||
\item Testing
|
\item Testing
|
||||||
\item (often) shorter code
|
\item (often) shorter code
|
||||||
\end{itemize}
|
\end{itemize}
|
||||||
Cons:
|
\uncover<+->{Cons:}
|
||||||
\begin{itemize}[<+->]
|
\begin{itemize}[<+->]
|
||||||
\item harder to learn
|
\item harder to learn
|
||||||
\item harder to understand
|
\item harder to understand
|
||||||
|
@ -81,6 +83,18 @@ int main() {
|
||||||
\end{itemize}
|
\end{itemize}
|
||||||
\end{frame}
|
\end{frame}
|
||||||
|
|
||||||
|
\begin{frame}{Languages}
|
||||||
|
\begin{itemize}[<+->]
|
||||||
|
\item Haskell(*)
|
||||||
|
\item Clojure(*) (runs in JVM)
|
||||||
|
\item F\#, OCaml
|
||||||
|
\item Ada, Lua, Scala
|
||||||
|
\item Lisp/Scheme and dialects (some (*))
|
||||||
|
\item JS, Python, Swift
|
||||||
|
\item Swift
|
||||||
|
\end{itemize}
|
||||||
|
\end{frame}
|
||||||
|
|
||||||
\subsection{Case study: Haskell}
|
\subsection{Case study: Haskell}
|
||||||
\begin{frame}{Overview}
|
\begin{frame}{Overview}
|
||||||
\begin{itemize}[<+->]
|
\begin{itemize}[<+->]
|
||||||
|
@ -95,7 +109,7 @@ int main() {
|
||||||
\end{frame}
|
\end{frame}
|
||||||
|
|
||||||
\begin{frame}[fragile]{Syntax – Functions}
|
\begin{frame}[fragile]{Syntax – Functions}
|
||||||
Function constraints, definition and calls:
|
Function definition and calls:
|
||||||
\begin{haskell}
|
\begin{haskell}
|
||||||
mysum :: Num a => a -> a -> a -> a
|
mysum :: Num a => a -> a -> a -> a
|
||||||
mysum x y z = x + y + z
|
mysum x y z = x + y + z
|
||||||
|
@ -103,7 +117,7 @@ mysum x y z = x + y + z
|
||||||
b = mysum 1 2 3
|
b = mysum 1 2 3
|
||||||
\end{haskell}
|
\end{haskell}
|
||||||
\pause
|
\pause
|
||||||
Functions always get evaluated left to right, thus the following works (\emph{Currying}):
|
Functions always get evaluated left to right, thus the following works (\emph{\enquote{Currying}}):
|
||||||
\begin{haskell}
|
\begin{haskell}
|
||||||
mysum2 = mysum 2
|
mysum2 = mysum 2
|
||||||
-- c == 12
|
-- c == 12
|
||||||
|
@ -158,7 +172,7 @@ c = addto b 4
|
||||||
\item Represent \enquote{anonymous} functions, i.e. locally defined functions
|
\item Represent \enquote{anonymous} functions, i.e. locally defined functions
|
||||||
without associated name
|
without associated name
|
||||||
\item Can simply be passed to algorithms, i.e. sort.
|
\item Can simply be passed to algorithms, i.e. sort.
|
||||||
\item Syntax: \haskellcmd{\var1 var2 -> retval}
|
\item Syntax: \haskellcmd{\var1 var2 -> retval} (The \haskellcmd{\} is for λ)
|
||||||
\end{itemize}
|
\end{itemize}
|
||||||
\end{frame}
|
\end{frame}
|
||||||
|
|
||||||
|
@ -177,7 +191,7 @@ c = addto b 4
|
||||||
\item \emph{Folds} (or sometimes \emph{reductions}) create single values
|
\item \emph{Folds} (or sometimes \emph{reductions}) create single values
|
||||||
using whole lists, i.e. sums over all elements
|
using whole lists, i.e. sums over all elements
|
||||||
\item Often implemented using recursion
|
\item Often implemented using recursion
|
||||||
\item Need a function, an initialization value and a list
|
\item Need a function, an initialisation value and a list
|
||||||
\end{itemize}
|
\end{itemize}
|
||||||
\end{frame}
|
\end{frame}
|
||||||
|
|
||||||
|
@ -191,11 +205,12 @@ msum = mfold (+) 0
|
||||||
g = msum [1..100]
|
g = msum [1..100]
|
||||||
\end{haskell}
|
\end{haskell}
|
||||||
\uncover<+->{Note that this gets pretty resource hungry with large
|
\uncover<+->{Note that this gets pretty resource hungry with large
|
||||||
lists, better use left-folds for this (see~\cite{whichfold})}
|
lists, better use left-folds for this (see~\cite{whichfold}, not shown
|
||||||
|
here as they are more complicated)}
|
||||||
\end{frame}
|
\end{frame}
|
||||||
|
|
||||||
\begin{frame}[fragile]{Example: Pythagorean triangles}
|
\begin{frame}[fragile]{Example: Pythagorean triangles}
|
||||||
Get all Pythagorean triangles with a hypotenuse off length at most 15:
|
Get all Pythagorean triangles with a hypotenuse of length at most 15:
|
||||||
\begin{haskell}
|
\begin{haskell}
|
||||||
> [(a,b,c) | a <- [1..15],
|
> [(a,b,c) | a <- [1..15],
|
||||||
b <- [1..a],
|
b <- [1..a],
|
||||||
|
@ -228,8 +243,8 @@ mbsort = bsort (\x y -> (x > y))
|
||||||
\begin{itemize}[<+->]
|
\begin{itemize}[<+->]
|
||||||
\item Obviously, python is not strictly functional…
|
\item Obviously, python is not strictly functional…
|
||||||
\item …but has functions as first class objects!
|
\item …but has functions as first class objects!
|
||||||
\item Some other stuff is widely used, but with another syntax…
|
\item Some other stuff is widely used, but with another syntax,…
|
||||||
\item …, although there are ways to get the \enquote{real} functional
|
\item … although there usually are ways to get the \enquote{real} functional
|
||||||
style.
|
style.
|
||||||
\item I use python3 here, python2 differs in some points.
|
\item I use python3 here, python2 differs in some points.
|
||||||
\end{itemize}
|
\end{itemize}
|
||||||
|
@ -243,7 +258,7 @@ mbsort = bsort (\x y -> (x > y))
|
||||||
\item \emph{Note:} Most functional list-functions return iterators in
|
\item \emph{Note:} Most functional list-functions return iterators in
|
||||||
python, not lists!
|
python, not lists!
|
||||||
\item Use \pycmd{list()} to cast Iterators, but this is usually not
|
\item Use \pycmd{list()} to cast Iterators, but this is usually not
|
||||||
necessary.
|
necessary (you use them as iterators either way).
|
||||||
\end{itemize}
|
\end{itemize}
|
||||||
\end{frame}
|
\end{frame}
|
||||||
|
|
||||||
|
@ -269,13 +284,14 @@ print(b)
|
||||||
|
|
||||||
\begin{frame}[fragile]{Fold}
|
\begin{frame}[fragile]{Fold}
|
||||||
\begin{itemize}[<+->]
|
\begin{itemize}[<+->]
|
||||||
\item From the python2 to python3 Changelog:
|
\item From the python2 to python3 changelog:
|
||||||
\begin{quote}
|
\begin{quote}
|
||||||
Removed `reduce()`. Use `functools.reduce()` if you really need it;
|
Removed `reduce()`. Use `functools.reduce()` if you really need it;
|
||||||
however, 99 percent of the time an explicit `for` loop is more
|
however, 99 percent of the time an explicit `for` loop is more
|
||||||
readable.
|
readable.
|
||||||
\end{quote}
|
\end{quote}
|
||||||
\item I disagree – Old-style is more explicit and still available from \pycmd{functools}
|
\item I disagree – Old-style is more explicit and still available from
|
||||||
|
\pycmd{functools}, plus reduce is faster with build-in functions.
|
||||||
\item Example – sum of squares
|
\item Example – sum of squares
|
||||||
\begin{pycode}
|
\begin{pycode}
|
||||||
from functools import reduce
|
from functools import reduce
|
||||||
|
@ -358,7 +374,7 @@ def mybubblesort(array,
|
||||||
\begin{itemize}[<+->]
|
\begin{itemize}[<+->]
|
||||||
\item \enquote{Classical} \cpp{} has a few functional elements…
|
\item \enquote{Classical} \cpp{} has a few functional elements…
|
||||||
\item …but lacks lambdas, for instance.
|
\item …but lacks lambdas, for instance.
|
||||||
\item This changed with the modern standards, starting from \cpp{}11.
|
\item This changed significantly with the modern standards, starting from \cpp{}11.
|
||||||
\end{itemize}
|
\end{itemize}
|
||||||
\end{frame}
|
\end{frame}
|
||||||
|
|
||||||
|
@ -369,7 +385,7 @@ def mybubblesort(array,
|
||||||
\item In \cpp{}, \emph{Iterators} are equivalent to lists in functional languages.
|
\item In \cpp{}, \emph{Iterators} are equivalent to lists in functional languages.
|
||||||
\item Examples of iterators include \cppcmd{vector} and \cppcmd{array}.
|
\item Examples of iterators include \cppcmd{vector} and \cppcmd{array}.
|
||||||
\item See~\cite{cppiter} for more information about the specific iterator
|
\item See~\cite{cppiter} for more information about the specific iterator
|
||||||
types and the prerequisites they bring.
|
types and the necessary prerequisites.
|
||||||
\end{itemize}
|
\end{itemize}
|
||||||
\end{frame}
|
\end{frame}
|
||||||
|
|
||||||
|
@ -509,7 +525,7 @@ auto sum(const auto&... args)
|
||||||
|
|
||||||
\begin{frame}[plain]{Thanks for listening!}{Any questions?}
|
\begin{frame}[plain]{Thanks for listening!}{Any questions?}
|
||||||
\href{https://git.f3l.de/pheerai/wtfunctional/}{Git-Repo with examples and
|
\href{https://git.f3l.de/pheerai/wtfunctional/}{Git-Repo with examples and
|
||||||
slides}: \url{git.f3l.de/pheerai/wtfunctional/}
|
slides}: \url{https://git.f3l.de/pheerai/wtfunctional/}
|
||||||
|
|
||||||
\begin{description}
|
\begin{description}
|
||||||
\item[Mail:] \url{oli_r@fg4f.de}
|
\item[Mail:] \url{oli_r@fg4f.de}
|
||||||
|
|
Loading…
Reference in a new issue