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
|
@ -27,8 +27,8 @@ using functional paradigms.
|
|||
|
||||
## Files ##
|
||||
|
||||
You may download both [the slides PDF][slides] in handout mode, and a
|
||||
[source archive][examples] of the examples used during the talk.
|
||||
You may download both [the slides PDF][ext-slides] in handout mode, and a
|
||||
[source archive][ext-examples] of the examples used during the talk.
|
||||
|
||||
## Structure ##
|
||||
|
||||
|
@ -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.
|
||||
|
||||
[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
|
||||
[f3lgit]: https://git.f3l.de/pheerai/wtfunctional
|
||||
[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
|
||||
[pygments]: http://pygments.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/
|
||||
[wtfoff]: https://www.pheerai.de/wtf/
|
||||
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
\usepackage{upquote}
|
||||
\usepackage[section, cache=true,]{minted}
|
||||
|
||||
\renewcommand{\MintedPygmentize}{/usr/bin/pygmentize}
|
||||
|
||||
\usemintedstyle{manni}
|
||||
|
||||
\newminted[ccode]{c}%
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
\documentclass[english]{beamer}
|
||||
\documentclass[english,aspectratio=43]{beamer}
|
||||
|
||||
\usepackage{babel}
|
||||
\usepackage{csquotes}
|
||||
\usepackage{tabularx}
|
||||
\usepackage{shellesc}
|
||||
\usepackage[backend=biber,]{biblatex}
|
||||
\bibliography{wtf}
|
||||
\renewcommand{\bibfont}{\small}
|
||||
|
@ -18,7 +19,8 @@
|
|||
|
||||
\title{WTFunctional}
|
||||
\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}
|
||||
|
||||
|
@ -39,7 +41,7 @@
|
|||
\section{Dafunc?}
|
||||
\subsection{Functional programming}
|
||||
\begin{frame}{Understanding functional paradigms}
|
||||
Here: so called \enquote{purely functional} paradigm.
|
||||
Here: so called \enquote{purely/strict functional} paradigm.
|
||||
\begin{itemize}
|
||||
\item<+-> Programming without \enquote{side-effects}
|
||||
\begin{itemize}
|
||||
|
@ -67,13 +69,13 @@ int main() {
|
|||
\end{frame}
|
||||
|
||||
\begin{frame}{Pros and Cons}
|
||||
Pros:
|
||||
\uncover<+->{Pros:}
|
||||
\begin{itemize}[<+->]
|
||||
\item Maintainability
|
||||
\item Testing
|
||||
\item (often) shorter code
|
||||
\end{itemize}
|
||||
Cons:
|
||||
\uncover<+->{Cons:}
|
||||
\begin{itemize}[<+->]
|
||||
\item harder to learn
|
||||
\item harder to understand
|
||||
|
@ -81,6 +83,18 @@ int main() {
|
|||
\end{itemize}
|
||||
\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}
|
||||
\begin{frame}{Overview}
|
||||
\begin{itemize}[<+->]
|
||||
|
@ -95,7 +109,7 @@ int main() {
|
|||
\end{frame}
|
||||
|
||||
\begin{frame}[fragile]{Syntax – Functions}
|
||||
Function constraints, definition and calls:
|
||||
Function definition and calls:
|
||||
\begin{haskell}
|
||||
mysum :: Num a => a -> a -> a -> a
|
||||
mysum x y z = x + y + z
|
||||
|
@ -103,7 +117,7 @@ mysum x y z = x + y + z
|
|||
b = mysum 1 2 3
|
||||
\end{haskell}
|
||||
\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}
|
||||
mysum2 = mysum 2
|
||||
-- c == 12
|
||||
|
@ -158,7 +172,7 @@ c = addto b 4
|
|||
\item Represent \enquote{anonymous} functions, i.e. locally defined functions
|
||||
without associated name
|
||||
\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{frame}
|
||||
|
||||
|
@ -177,7 +191,7 @@ c = addto b 4
|
|||
\item \emph{Folds} (or sometimes \emph{reductions}) create single values
|
||||
using whole lists, i.e. sums over all elements
|
||||
\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{frame}
|
||||
|
||||
|
@ -191,11 +205,12 @@ msum = mfold (+) 0
|
|||
g = msum [1..100]
|
||||
\end{haskell}
|
||||
\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}
|
||||
|
||||
\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}
|
||||
> [(a,b,c) | a <- [1..15],
|
||||
b <- [1..a],
|
||||
|
@ -228,8 +243,8 @@ mbsort = bsort (\x y -> (x > y))
|
|||
\begin{itemize}[<+->]
|
||||
\item Obviously, python is not strictly functional…
|
||||
\item …but has functions as first class objects!
|
||||
\item Some other stuff is widely used, but with another syntax…
|
||||
\item …, although there are ways to get the \enquote{real} functional
|
||||
\item Some other stuff is widely used, but with another syntax,…
|
||||
\item … although there usually are ways to get the \enquote{real} functional
|
||||
style.
|
||||
\item I use python3 here, python2 differs in some points.
|
||||
\end{itemize}
|
||||
|
@ -243,7 +258,7 @@ mbsort = bsort (\x y -> (x > y))
|
|||
\item \emph{Note:} Most functional list-functions return iterators in
|
||||
python, not lists!
|
||||
\item Use \pycmd{list()} to cast Iterators, but this is usually not
|
||||
necessary.
|
||||
necessary (you use them as iterators either way).
|
||||
\end{itemize}
|
||||
\end{frame}
|
||||
|
||||
|
@ -269,13 +284,14 @@ print(b)
|
|||
|
||||
\begin{frame}[fragile]{Fold}
|
||||
\begin{itemize}[<+->]
|
||||
\item From the python2 to python3 Changelog:
|
||||
\item From the python2 to python3 changelog:
|
||||
\begin{quote}
|
||||
Removed `reduce()`. Use `functools.reduce()` if you really need it;
|
||||
however, 99 percent of the time an explicit `for` loop is more
|
||||
readable.
|
||||
\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
|
||||
\begin{pycode}
|
||||
from functools import reduce
|
||||
|
@ -358,7 +374,7 @@ def mybubblesort(array,
|
|||
\begin{itemize}[<+->]
|
||||
\item \enquote{Classical} \cpp{} has a few functional elements…
|
||||
\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{frame}
|
||||
|
||||
|
@ -369,7 +385,7 @@ def mybubblesort(array,
|
|||
\item In \cpp{}, \emph{Iterators} are equivalent to lists in functional languages.
|
||||
\item Examples of iterators include \cppcmd{vector} and \cppcmd{array}.
|
||||
\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{frame}
|
||||
|
||||
|
@ -509,7 +525,7 @@ auto sum(const auto&... args)
|
|||
|
||||
\begin{frame}[plain]{Thanks for listening!}{Any questions?}
|
||||
\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}
|
||||
\item[Mail:] \url{oli_r@fg4f.de}
|
||||
|
|
Loading…
Reference in a new issue