Improve configuration modularity, use minted for inline code
This commit is contained in:
parent
9d9ddfaf2d
commit
22f0fd9447
@ -8,7 +8,7 @@ data WeekDay = Monday
|
|||||||
| Saturday
|
| Saturday
|
||||||
| Sunday
|
| Sunday
|
||||||
\end{haskellcode}
|
\end{haskellcode}
|
||||||
This declares the new data type \code{WeekDay} with 7 \emph{constructors}. That means \code{Monday}, \code{Tuesday} etc. are all values of the type \code{WeekDay}.
|
This declares the new data type \hinline{WeekDay} with 7 \emph{constructors}. That means \hinline{Monday}, \hinline{Tuesday} etc. are all values of the type \hinline{WeekDay}.
|
||||||
\pause
|
\pause
|
||||||
\\
|
\\
|
||||||
We could now define a whole week, by creating a list:
|
We could now define a whole week, by creating a list:
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
And we can again \emph{pattern match} on our \code{WeekDay} type. Let's find out if a given day is a Monday:
|
And we can again \emph{pattern match} on our \hinline{WeekDay} type. Let's find out if a given day is a Monday:
|
||||||
\pause
|
\pause
|
||||||
\begin{haskellcode}
|
\begin{haskellcode}
|
||||||
isMonday :: WeekDay -> Bool
|
isMonday :: WeekDay -> Bool
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
But we can do more than enumerations. How about we do some error handling? Let's say we want a function to return an \code{Int}, but in case something went horribly wrong, we don't just want to return a 0 or some magic number, but a proper error message. Here we go:
|
But we can do more than enumerations. How about we do some error handling? Let's say we want a function to return an \hinline{Int}, but in case something went horribly wrong, we don't just want to return a 0 or some magic number, but a proper error message. Here we go:
|
||||||
\pause
|
\pause
|
||||||
\begin{haskellcode}
|
\begin{haskellcode}
|
||||||
data MaybeInt = NoError Int
|
data MaybeInt = NoError Int
|
||||||
|
@ -12,4 +12,4 @@ addIntToList :: MaybeInt -> [Int]
|
|||||||
addIntToList (NoError x) = [x]
|
addIntToList (NoError x) = [x]
|
||||||
addIntToList (Error str) = []
|
addIntToList (Error str) = []
|
||||||
\end{haskellcode}
|
\end{haskellcode}
|
||||||
So if we got an error, we just return an empty list, otherwise we return a list with the \code{Int} as its only element.
|
So if we got an error, we just return an empty list, otherwise we return a list with the \hinline{Int} as its only element.
|
@ -8,16 +8,16 @@ Uh... that looks mean. Let's examine this.\\
|
|||||||
\pause
|
\pause
|
||||||
We have:
|
We have:
|
||||||
\begin{itemizep}
|
\begin{itemizep}
|
||||||
\item defined a data type \code{Tree}
|
\item defined a data type \hinline{Tree}
|
||||||
\item a constructor \code{Leaf} of type \code{Tree} with one arguments of type \code{Char}
|
\item a constructor \hinline{Leaf} of type \hinline{Tree} with one arguments of type \hinline{Char}
|
||||||
\item a constructor \code{Node} of type \code{Tree} with 3 arguments
|
\item a constructor \hinline{Node} of type \hinline{Tree} with 3 arguments
|
||||||
\begin{itemizep}
|
\begin{itemizep}
|
||||||
\item \code{Tree}
|
\item \hinline{Tree}
|
||||||
\item \code{Int}
|
\item \hinline{Int}
|
||||||
\item \code{Tree}
|
\item \hinline{Tree}
|
||||||
\end{itemizep}
|
\end{itemizep}
|
||||||
\end{itemizep}
|
\end{itemizep}
|
||||||
\slidep
|
\slidep
|
||||||
That means: a \code{Tree} can either be a \code{Leaf} or an internal \code{Node} with two sub-trees. If we want to create a \code{Leaf}, we have to pass the constructor a \code{Char}. If we want to create a \code{Node}, we have to pass 3 arguments, in order: another \code{Tree}, an \code{Int} and yet another \code{Tree}.\\
|
That means: a \hinline{Tree} can either be a \hinline{Leaf} or an internal \hinline{Node} with two sub-trees. If we want to create a \hinline{Leaf}, we have to pass the constructor a \hinline{Char}. If we want to create a \hinline{Node}, we have to pass 3 arguments, in order: another \hinline{Tree}, an \hinline{Int} and yet another \hinline{Tree}.\\
|
||||||
So we can save information in the leafs (\code{Char}) and in the internal nodes (\code{Int}).\\
|
So we can save information in the leafs (\hinline{Char}) and in the internal nodes (\hinline{Int}).\\
|
||||||
This is just an example. There are endless more ways of trees.
|
This is just an example. There are endless more ways of trees.
|
@ -7,4 +7,4 @@ mod2 x
|
|||||||
| x - 2 < 0 = x
|
| x - 2 < 0 = x
|
||||||
| otherwise = mod2 (x - 2)
|
| otherwise = mod2 (x - 2)
|
||||||
\end{haskellcode}
|
\end{haskellcode}
|
||||||
These \verb#|# things above are called \textbf{guards} and are similar to \emph{pattern matching}. They are processed in order. If the condition on the left side of the equation is true, then it returns what stands on the right side of the equation. If it's false, then it processes the next line.\\ \code{otherwise} on the last line is just defined as \code{True}, to make these constructs easier to read and catch all other cases of input.
|
These \verb#|# things above are called \textbf{guards} and are similar to \emph{pattern matching}. They are processed in order. If the condition on the left side of the equation is true, then it returns what stands on the right side of the equation. If it's false, then it processes the next line.\\ \hinline{otherwise} on the last line is just defined as \hinline{True}, to make these constructs easier to read and catch all other cases of input.
|
@ -1,12 +1,12 @@
|
|||||||
The list is probably the most basic data structure in Haskell. Like the array in C. It is a singly-linked list and is very lazy. The compiler has numerous ways to optimize lists, so don't be afraid to use them, even for huge things.
|
The list is probably the most basic data structure in Haskell. Like the array in C. It is a singly-linked list and is very lazy. The compiler has numerous ways to optimize lists, so don't be afraid to use them, even for huge things.
|
||||||
\pause
|
\pause
|
||||||
We build lists by using either the \code{[]} notation:
|
We build lists by using either the \hinline{[]} notation:
|
||||||
\begin{haskellcode}
|
\begin{haskellcode}
|
||||||
list1 :: [Integer]
|
list1 :: [Integer]
|
||||||
list1 = [1, 2]
|
list1 = [1, 2]
|
||||||
\end{haskellcode}
|
\end{haskellcode}
|
||||||
\pause
|
\pause
|
||||||
or by using the \emph{cons} operator \code{(:)} which takes an element and a list and produces a new list with the element prepended to the front.
|
or by using the \emph{cons} operator \hinline{(:)} which takes an element and a list and produces a new list with the element prepended to the front.
|
||||||
\begin{haskellcode}
|
\begin{haskellcode}
|
||||||
emptyList = []
|
emptyList = []
|
||||||
|
|
||||||
|
@ -12,4 +12,4 @@ sumEveryTwo [] = 0
|
|||||||
sumEveryTwo (x:[]) = [x]
|
sumEveryTwo (x:[]) = [x]
|
||||||
sumEveryTwo (x:(y:zs)) = (x + y) : sumEveryTwo zs
|
sumEveryTwo (x:(y:zs)) = (x + y) : sumEveryTwo zs
|
||||||
\end{haskellcode}
|
\end{haskellcode}
|
||||||
Note that \code{(x:(y:zs))} may also be written as \code{(x:y:zs)}.
|
Note that \hinline{(x:(y:zs))} may also be written as \hinline{(x:y:zs)}.
|
@ -16,4 +16,4 @@ Now let's say we want all numbers between 50 and 100 that have the remainder 0 w
|
|||||||
\begin{haskellcode*}{bgcolor=mygrey,frame=single,numbers=none,label=GHCi}
|
\begin{haskellcode*}{bgcolor=mygrey,frame=single,numbers=none,label=GHCi}
|
||||||
> [x | x <- [50..100], mod x 12 == 0]
|
> [x | x <- [50..100], mod x 12 == 0]
|
||||||
\end{haskellcode*}
|
\end{haskellcode*}
|
||||||
\code{x <- [50..100]} is the binding, while \code{mod x 12 == 0} is the predicate, separated by a comma. We can have multiple predicates.
|
\hinline{x <- [50..100]} is the binding, while \hinline{mod x 12 == 0} is the predicate, separated by a comma. We can have multiple predicates.
|
@ -8,4 +8,4 @@ sumPair :: (Int, Int) -> Int
|
|||||||
sumPair (x, y) = x + y
|
sumPair (x, y) = x + y
|
||||||
\end{haskellcode}
|
\end{haskellcode}
|
||||||
\pause
|
\pause
|
||||||
Note: we use \code{(x, y)} notation for both the type and the definition! Those are still two different things. We can also have triples, quadruples etc.
|
Note: we use \hinline{(x, y)} notation for both the type and the definition! Those are still two different things. We can also have triples, quadruples etc.
|
@ -4,7 +4,7 @@
|
|||||||
\item everything (variables, data structures...) is \emph{immutable}
|
\item everything (variables, data structures...) is \emph{immutable}
|
||||||
\item expressions never have side-effects (remember: mathematical functions)
|
\item expressions never have side-effects (remember: mathematical functions)
|
||||||
\item same input $\mapsto$ same output... \emph{always}!
|
\item same input $\mapsto$ same output... \emph{always}!
|
||||||
\item replace a function with it's (return) value? Yes. What happens in C or java if you do that? Remember \code{void pop();}?
|
\item replace a function with it's (return) value? Yes. What happens in C or java if you do that? Remember \cppinline{void pop();}?
|
||||||
\end{itemizep}
|
\end{itemizep}
|
||||||
\slidep
|
\slidep
|
||||||
\vspace{\baselineskip}
|
\vspace{\baselineskip}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
But let's not stop here. What does the dot \code{(.)} actually mean?
|
But let's not stop here. What does the dot \hinline{(.)} actually mean?
|
||||||
\vspace{\baselineskip}
|
\vspace{\baselineskip}
|
||||||
\\
|
\\
|
||||||
\pause
|
\pause
|
||||||
It's just a function (the \emph{prefix} version of \code{.})! Here is the type signature:
|
It's just a function (the \emph{prefix} version of \hinline{.})! Here is the type signature:
|
||||||
\begin{haskellcode}
|
\begin{haskellcode}
|
||||||
(.) :: (b -> c) -> (a -> b) -> a -> c
|
(.) :: (b -> c) -> (a -> b) -> a -> c
|
||||||
\end{haskellcode}
|
\end{haskellcode}
|
||||||
|
@ -13,4 +13,4 @@ Did you just notice the braces? They are \textbf{very} important! So, currying i
|
|||||||
f :: Int -> Int -> Int
|
f :: Int -> Int -> Int
|
||||||
f :: Int -> (Int -> Int)
|
f :: Int -> (Int -> Int)
|
||||||
\end{haskellcode}
|
\end{haskellcode}
|
||||||
On the other hand function application is \emph{left}-associative, so \code{f 3 2} is just a shorthand of \code{(f 3) 2}. Makes sense?
|
On the other hand function application is \emph{left}-associative, so \hinline{f 3 2} is just a shorthand of \hinline{(f 3) 2}. Makes sense?
|
@ -7,11 +7,9 @@ addInt x y = x + y
|
|||||||
addTwo :: Int -> Int
|
addTwo :: Int -> Int
|
||||||
addTwo = addInt 2
|
addTwo = addInt 2
|
||||||
\end{haskellcode}
|
\end{haskellcode}
|
||||||
You probably noticed that we did not write \code{addTwo x = ...}, but why would we? We gave \code{addInt} one argument, so the arity (we called it dimension in the gemoetrical example) is one less, but there is still one parameter left we can pass in.
|
You probably noticed that we did not write \hinline{addTwo x = ...}, but why would we? We gave \hinline{addInt} one argument, so the arity (we called it dimension in the gemoetrical example) is one less, but there is still one parameter left we can pass in.
|
||||||
\vspace{\baselineskip}
|
|
||||||
\\
|
|
||||||
\pause
|
\pause
|
||||||
The reason we can omit the \code{x} here is that
|
The reason we can omit the \hinline{x} here is that
|
||||||
\begin{haskellcode}
|
\begin{haskellcode}
|
||||||
f x y z = ...
|
f x y z = ...
|
||||||
\end{haskellcode}
|
\end{haskellcode}
|
||||||
|
@ -7,13 +7,13 @@ fold z f (x:xs) = x `f` (fold z f xs)
|
|||||||
Whoa! What's going on here?\\
|
Whoa! What's going on here?\\
|
||||||
Let's see...
|
Let's see...
|
||||||
\begin{itemizep}
|
\begin{itemizep}
|
||||||
\item \code{z} is what we return if the list is empty
|
\item \hinline{z} is what we return if the list is empty
|
||||||
\item \code{f} is our function (e.g. \code{(*)} or \code{(+)})
|
\item \hinline{f} is our function (e.g. \hinline{(*)} or \hinline{(+)})
|
||||||
\item and the last remaining argument is the actual list we are working on
|
\item and the last remaining argument is the actual list we are working on
|
||||||
\end{itemizep}
|
\end{itemizep}
|
||||||
\slidep
|
\slidep
|
||||||
The function application has the following form:\\
|
The function application has the following form:\\
|
||||||
\code{fold f z [a,b,c] == a `f` (b `f` (c `f` z))}
|
\hinline{fold f z [a,b,c] == a `f` (b `f` (c `f` z))}
|
||||||
\vspace{\baselineskip}
|
\vspace{\baselineskip}
|
||||||
\\
|
\\
|
||||||
This folds from the right, so the \emph{Prelude} already defines a function which is very similar to ours and called \textbf{foldr}.
|
This folds from the right, so the \emph{Prelude} already defines a function which is very similar to ours and called \textbf{foldr}.
|
@ -1,4 +1,4 @@
|
|||||||
So how do our \code{sum}, \code{prod} and \code{length} functions look like if we use our \code{fold} abstraction?
|
So how do our \hinline{sum}, \hinline{prod} and \hinline{length} functions look like if we use our \hinline{fold} abstraction?
|
||||||
\pause
|
\pause
|
||||||
\begin{haskellcode}
|
\begin{haskellcode}
|
||||||
sum :: [Int] -> Int
|
sum :: [Int] -> Int
|
||||||
|
@ -4,7 +4,7 @@ To summarize:
|
|||||||
foldr f z [a,b,c] == a `f` (b `f` (c `f` z))
|
foldr f z [a,b,c] == a `f` (b `f` (c `f` z))
|
||||||
foldl f z [a,b,c] == ((z `f` a) `f` b) `f` c
|
foldl f z [a,b,c] == ((z `f` a) `f` b) `f` c
|
||||||
\end{haskellcode}
|
\end{haskellcode}
|
||||||
For \code{foldl} the \code{z} is sort of the starting value.
|
For \hinline{foldl} the \hinline{z} is sort of the starting value.
|
||||||
\vspace{\baselineskip}
|
\vspace{\baselineskip}
|
||||||
\\
|
\\
|
||||||
\pause
|
\pause
|
||||||
@ -12,10 +12,7 @@ We can even express foldl in terms of foldr and vice versa. If you are intereste
|
|||||||
\vspace{\baselineskip}
|
\vspace{\baselineskip}
|
||||||
\\
|
\\
|
||||||
You should definitely look them up in the Prelude and play with them: \url{https://hackage.haskell.org/package/base-4.8.0.0/docs/Prelude.html}
|
You should definitely look them up in the Prelude and play with them: \url{https://hackage.haskell.org/package/base-4.8.0.0/docs/Prelude.html}
|
||||||
\vspace{\baselineskip}
|
\begin{haskellcode*}{bgcolor=mygrey,frame=single,numbers=none,label=GHCi}
|
||||||
\\
|
|
||||||
GHCi...
|
|
||||||
\begin{haskellcode}
|
|
||||||
> foldr (-) 0 [1, 2, 3]
|
> foldr (-) 0 [1, 2, 3]
|
||||||
> foldl (-) 0 [1, 2, 3]
|
> foldl (-) 0 [1, 2, 3]
|
||||||
\end{haskellcode}
|
\end{haskellcode*}
|
@ -1,4 +1,4 @@
|
|||||||
Another way which is very similar would be using \code{let}:
|
Another way which is very similar would be using \hinline{let}:
|
||||||
\begin{haskellcode}
|
\begin{haskellcode}
|
||||||
f :: Int -> Int
|
f :: Int -> Int
|
||||||
f x = let y p = x + p
|
f x = let y p = x + p
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
These look almost the same, but they are different constructs. \code{where} is bound to the pattern matching \code{f x =} and may also have access to parts of a function that are not syntactically expressions, e.g.:
|
These look almost the same, but they are different constructs. \hinline{where} is bound to the pattern matching \hinline{f x =} and may also have access to parts of a function that are not syntactically expressions, e.g.:
|
||||||
\begin{haskellcode}
|
\begin{haskellcode}
|
||||||
f x
|
f x
|
||||||
| cond1 x = a
|
| cond1 x = a
|
||||||
@ -7,11 +7,11 @@ f x
|
|||||||
where
|
where
|
||||||
a = w x
|
a = w x
|
||||||
\end{haskellcode}
|
\end{haskellcode}
|
||||||
While that is not possible with \code{let}, which is an actual expression and can be used whenever expressions are allowed (e.g. inside \emph{Monads}, we'll know more about these in a few weeks).
|
While that is not possible with \hinline{let}, which is an actual expression and can be used whenever expressions are allowed (e.g. inside \emph{Monads}, we'll know more about these in a few weeks).
|
||||||
\vspace{\baselineskip}
|
\vspace{\baselineskip}
|
||||||
\\
|
\\
|
||||||
There are a few more intricacies, but most of the time this is just style consideration:\\ \url{https://wiki.haskell.org/Let_vs._Where}
|
There are a few more intricacies, but most of the time this is just style consideration:\\ \url{https://wiki.haskell.org/Let_vs._Where}
|
||||||
\pause
|
\pause
|
||||||
\vspace{\baselineskip}
|
\vspace{\baselineskip}
|
||||||
\\
|
\\
|
||||||
How would we have to rewrite the function in order to use \code{let}?
|
How would we have to rewrite the function in order to use \hinline{let}?
|
@ -1,7 +1,7 @@
|
|||||||
Let's say we have a list of \code{Int} and want to add \code{2} to every element of the list.
|
Let's say we have a list of \hinline{Int} and want to add \hinline{2} to every element of the list.
|
||||||
\begin{haskellcode}
|
\begin{haskellcode}
|
||||||
addTwo :: [Int] -> [Int]
|
addTwo :: [Int] -> [Int]
|
||||||
addTwo ... ?
|
addTwo ... ?
|
||||||
\end{haskellcode}
|
\end{haskellcode}
|
||||||
\pause
|
\pause
|
||||||
\textbf{Exercise:} Find the answer! 5 minutes time, remember the \emph{cons} operator \code{(:)}, pattern matching on lists and ofc recursion! Start with the case of an empty list.
|
\textbf{Exercise:} Find the answer! 5 minutes time, remember the \emph{cons} operator \hinline{(:)}, pattern matching on lists and ofc recursion! Start with the case of an empty list.
|
@ -13,4 +13,4 @@ map :: (a -> b) -> [a] -> [b]
|
|||||||
map f [] = []
|
map f [] = []
|
||||||
map f (x:xs) = f x : map f xs
|
map f (x:xs) = f x : map f xs
|
||||||
\end{haskellcode}
|
\end{haskellcode}
|
||||||
So we don't really know what the function \code{f} does, but we know that it converts one element of the list to something else. We \emph{map} a function over a list! Hence the name.
|
So we don't really know what the function \hinline{f} does, but we know that it converts one element of the list to something else. We \emph{map} a function over a list! Hence the name.
|
@ -12,4 +12,4 @@ absList xs = map (\x -> abs x) xs
|
|||||||
absList = map abs
|
absList = map abs
|
||||||
\end{haskellcode}
|
\end{haskellcode}
|
||||||
\pause
|
\pause
|
||||||
Cool, right? So now we have abstracted out the \textbf{recursion pattern} that is all the same for those 3 functions. \code{map} is actually part of the standard library (called \emph{Prelude}).
|
Cool, right? So now we have abstracted out the \textbf{recursion pattern} that is all the same for those 3 functions. \hinline{map} is actually part of the standard library (called \emph{Prelude}).
|
@ -3,14 +3,14 @@ Now you know how a regular function looks like, e.g:
|
|||||||
f :: Int -> Int
|
f :: Int -> Int
|
||||||
f x = x + 1
|
f x = x + 1
|
||||||
\end{haskellcode}
|
\end{haskellcode}
|
||||||
But now imagine we need a helper function which is very specific to the current function. In C we would have to define this new helper function at top-level and would probably make it \code{static}.
|
But now imagine we need a helper function which is very specific to the current function. In C we would have to define this new helper function at top-level and would probably make it \cinline{static}.
|
||||||
\pause
|
\pause
|
||||||
\vspace{\baselineskip}
|
\vspace{\baselineskip}
|
||||||
\\
|
\\
|
||||||
Haskell allows us to \textbf{inline} functions in a few more ways, e.g.:
|
Haskell allows us to \textbf{inline} functions in a few more ways, e.g.:
|
||||||
\begin{itemizep}
|
\begin{itemizep}
|
||||||
\item with \code{where}
|
\item with \hinline{where}
|
||||||
\item with \code{let...in}
|
\item with \hinline{let...in}
|
||||||
\item anonymously (lambda abstraction)
|
\item anonymously (lambda abstraction)
|
||||||
\end{itemizep}
|
\end{itemizep}
|
||||||
\slidep
|
\slidep
|
||||||
|
@ -13,7 +13,7 @@ Whatever the function does... it has something of one type and returns something
|
|||||||
\vspace{\baselineskip}
|
\vspace{\baselineskip}
|
||||||
\\
|
\\
|
||||||
\pause
|
\pause
|
||||||
Similarly, remember the function \code{head} which gives us the first element of a list? The type signature actually looks like this:
|
Similarly, remember the function \hinline{head} which gives us the first element of a list? The type signature actually looks like this:
|
||||||
\begin{haskellcode}
|
\begin{haskellcode}
|
||||||
head :: [a] -> a
|
head :: [a] -> a
|
||||||
\end{haskellcode}
|
\end{haskellcode}
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
\begin{itemize}
|
\begin{itemize}
|
||||||
\item what is the difference between \code{let} and \code{where}?
|
\item what is the difference between \hinline{let} and \hinline{where}?
|
||||||
\item what is the difference between \code{foldr} and \code{foldl}?
|
\item what is the difference between \hinline{foldr} and \hinline{foldl}?
|
||||||
\item what is the difference between explicit and implicit recursion? Give examples
|
\item what is the difference between explicit and implicit recursion? Give examples
|
||||||
\item how many arguments does a haskell function have (strictly speaking)?
|
\item how many arguments does a haskell function have (strictly speaking)?
|
||||||
\item what do you have to keep in mind in order to make function composition work?
|
\item what do you have to keep in mind in order to make function composition work?
|
||||||
\item can you define map and filter in terms of foldr?
|
\item can you define \hinline{map} and \hinline{filter} in terms of \hinline{foldr}?
|
||||||
\item what is eta reduction (or: eta abstraction)?
|
\item what is eta reduction (or: eta abstraction)?
|
||||||
\end{itemize}
|
\end{itemize}
|
@ -1,4 +1,4 @@
|
|||||||
We use \code{where} to define a helper function:
|
We use \hinline{where} to define a helper function:
|
||||||
\begin{haskellcode}
|
\begin{haskellcode}
|
||||||
f :: Int -> Int
|
f :: Int -> Int
|
||||||
f x = x + (y 2)
|
f x = x + (y 2)
|
||||||
|
@ -14,15 +14,10 @@
|
|||||||
\usepackage[T1]{fontenc}
|
\usepackage[T1]{fontenc}
|
||||||
\usepackage[Q=yes]{examplep}
|
\usepackage[Q=yes]{examplep}
|
||||||
|
|
||||||
|
\input{../common/common_configuration.tex}
|
||||||
|
|
||||||
% package configuration
|
% package configuration
|
||||||
\DeclareGraphicsExtensions{.pdf,.png,.jpg}
|
\DeclareGraphicsExtensions{.pdf,.png,.jpg}
|
||||||
\usemintedstyle{friendly}
|
|
||||||
\newminted{haskell}{frame=single,numbers=left,samepage=true}
|
|
||||||
\newminted{cpp}{frame=single,numbers=left}
|
|
||||||
\newminted{c}{frame=single,numbers=left}
|
|
||||||
\renewcommand{\theFancyVerbLine}{\ttfamily
|
|
||||||
\textcolor[rgb]{0.0,0.0,0.0}{\footnotesize
|
|
||||||
\oldstylenums{\arabic{FancyVerbLine}}}}
|
|
||||||
|
|
||||||
% macros and environments
|
% macros and environments
|
||||||
\NewDocumentCommand {\slide} { m O{} O{} }
|
\NewDocumentCommand {\slide} { m O{} O{} }
|
||||||
@ -34,7 +29,3 @@
|
|||||||
\newenvironment{itemizep}
|
\newenvironment{itemizep}
|
||||||
{\begin{itemize}}
|
{\begin{itemize}}
|
||||||
{\end{itemize}}
|
{\end{itemize}}
|
||||||
|
|
||||||
% color definition
|
|
||||||
\definecolor{solarized}{HTML}{002B36}
|
|
||||||
\definecolor{mygreen}{rgb}{0,0.6,0}
|
|
@ -6,55 +6,26 @@
|
|||||||
\usepackage{amssymb}
|
\usepackage{amssymb}
|
||||||
\usepackage{graphicx}
|
\usepackage{graphicx}
|
||||||
\usepackage{listings}
|
\usepackage{listings}
|
||||||
\usepackage{minted}
|
\usepackage[newfloat=true]{minted}
|
||||||
\usepackage{xparse}
|
\usepackage{xparse}
|
||||||
|
|
||||||
% for \verb inside \item
|
% for \verb inside \item
|
||||||
\usepackage[T1]{fontenc}
|
\usepackage[T1]{fontenc}
|
||||||
\usepackage[Q=yes]{examplep}
|
\usepackage[Q=yes]{examplep}
|
||||||
|
|
||||||
% color definition
|
\input{../common/common_configuration.tex}
|
||||||
\definecolor{solarized}{HTML}{002B36}
|
|
||||||
\definecolor{mygreen}{HTML}{009900}
|
|
||||||
\definecolor{mygrey}{rgb}{0.95,0.95,0.95}
|
|
||||||
|
|
||||||
% package configuration
|
% package configuration
|
||||||
\DeclareGraphicsExtensions{.pdf,.png,.jpg}
|
\DeclareGraphicsExtensions{.pdf,.png,.jpg}
|
||||||
\beamertemplatenavigationsymbolsempty
|
\beamertemplatenavigationsymbolsempty
|
||||||
\setbeamertemplate{footline}[frame number]
|
\setbeamertemplate{footline}[frame number]
|
||||||
|
|
||||||
% minted
|
|
||||||
%% fix the minted@colorbg environment
|
|
||||||
\makeatletter
|
|
||||||
\renewenvironment{minted@colorbg}[1]
|
|
||||||
{\def\minted@bgcol{#1}%
|
|
||||||
\noindent
|
|
||||||
\begin{lrbox}{\minted@bgbox}
|
|
||||||
\begin{minipage}{\linewidth-2\fboxsep}}
|
|
||||||
{\end{minipage}%
|
|
||||||
\end{lrbox}%
|
|
||||||
\setlength{\topsep}{\smallskipamount}% set the vertical space
|
|
||||||
\trivlist\item\relax % ensure going to a new line
|
|
||||||
\colorbox{\minted@bgcol}{\usebox{\minted@bgbox}}%
|
|
||||||
\endtrivlist % close the trivlist
|
|
||||||
}
|
|
||||||
\makeatother
|
|
||||||
\usemintedstyle{friendly}
|
|
||||||
\newminted{haskell}{bgcolor=mygrey,frame=single,numbers=left}
|
|
||||||
\newminted{cpp}{bgcolor=mygrey,frame=single,numbers=left}
|
|
||||||
\newminted{c}{bgcolor=mygrey,frame=single,numbers=left}
|
|
||||||
\renewcommand{\theFancyVerbLine}{\ttfamily
|
|
||||||
\textcolor[rgb]{0.0,0.0,0.0}{\footnotesize
|
|
||||||
\oldstylenums{\arabic{FancyVerbLine}}}}
|
|
||||||
|
|
||||||
% macros and environments
|
% macros and environments
|
||||||
\newcommand{\code}[1]{\texttt{#1}}
|
|
||||||
\newcommand{\slidep}{\onslide<+->}
|
\newcommand{\slidep}{\onslide<+->}
|
||||||
\newenvironment{itemizep}
|
\newenvironment{itemizep}
|
||||||
{\begin{itemize}[<+->]}
|
{\begin{itemize}[<+->]}
|
||||||
{\end{itemize}}
|
{\end{itemize}}
|
||||||
|
|
||||||
|
|
||||||
\NewDocumentCommand {\slide} { m O{} O{} }
|
\NewDocumentCommand {\slide} { m O{} O{} }
|
||||||
{\begin{frame}{#3}
|
{\begin{frame}{#3}
|
||||||
\frametitle{\thesection.\ifnum\thesubsection=0\else\thesubsection.\fi\ \currentname {#2}}
|
\frametitle{\thesection.\ifnum\thesubsection=0\else\thesubsection.\fi\ \currentname {#2}}
|
||||||
@ -67,8 +38,7 @@
|
|||||||
\tableofcontents[currentsection,hideothersubsections]
|
\tableofcontents[currentsection,hideothersubsections]
|
||||||
\end{frame}}
|
\end{frame}}
|
||||||
|
|
||||||
|
% sections numbered
|
||||||
% sections numbered
|
|
||||||
\setbeamertemplate{section in toc}[sections numbered]
|
\setbeamertemplate{section in toc}[sections numbered]
|
||||||
\setbeamertemplate{subsection in toc}[subsections numbered]
|
\setbeamertemplate{subsection in toc}[subsections numbered]
|
||||||
\defbeamertemplate{subsubsection in toc}{subsubsections numbered}
|
\defbeamertemplate{subsubsection in toc}{subsubsections numbered}
|
||||||
|
32
common/common_configuration.tex
Normal file
32
common/common_configuration.tex
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
% color definition
|
||||||
|
\definecolor{solarized}{HTML}{002B36}
|
||||||
|
\definecolor{mygreen}{HTML}{009900}
|
||||||
|
\definecolor{myblue}{HTML}{0000FF}
|
||||||
|
\definecolor{mygrey}{rgb}{0.95,0.95,0.95}
|
||||||
|
|
||||||
|
% minted
|
||||||
|
%% fix the minted@colorbg environment
|
||||||
|
\makeatletter
|
||||||
|
\renewenvironment{minted@colorbg}[1]
|
||||||
|
{\def\minted@bgcol{#1}%
|
||||||
|
\noindent
|
||||||
|
\begin{lrbox}{\minted@bgbox}
|
||||||
|
\begin{minipage}{\linewidth-2\fboxsep}}
|
||||||
|
{\end{minipage}%
|
||||||
|
\end{lrbox}%
|
||||||
|
\setlength{\topsep}{\smallskipamount}% set the vertical space
|
||||||
|
\trivlist\item\relax % ensure going to a new line
|
||||||
|
\colorbox{\minted@bgcol}{\usebox{\minted@bgbox}}%
|
||||||
|
\endtrivlist % close the trivlist
|
||||||
|
}
|
||||||
|
\makeatother
|
||||||
|
\usemintedstyle{friendly}
|
||||||
|
\newminted{haskell}{bgcolor=mygrey,frame=single,numbers=left}
|
||||||
|
\newminted{cpp}{bgcolor=mygrey,frame=single,numbers=left}
|
||||||
|
\newminted{c}{bgcolor=mygrey,frame=single,numbers=left}
|
||||||
|
\newcommand{\hinline}[1]{\mintinline{haskell}{#1}}
|
||||||
|
\newcommand{\cinline}[1]{\mintinline{c}{#1}}
|
||||||
|
\newcommand{\cppinline}[1]{\mintinline{cpp}{#1}}
|
||||||
|
\renewcommand{\theFancyVerbLine}{\ttfamily
|
||||||
|
\textcolor[rgb]{0.0,0.0,0.0}{\footnotesize
|
||||||
|
\oldstylenums{\arabic{FancyVerbLine}}}}
|
Loading…
Reference in New Issue
Block a user