Skip to content
Snippets Groups Projects
Verified Commit b94d8c9b authored by jonahbeneb02's avatar jonahbeneb02
Browse files

Add english translation of 10th sheet

parent 615b5e92
No related branches found
No related tags found
No related merge requests found
File added
%Original Template von Nicolas Lehman, angepasst von Wolfgang Mulzer und Katharina Klost
% Dokumentenklasse
\documentclass[
% globale Schriftgröße
10pt,
% setzt Absatzabstand hoch
parskip=half-,
% Format
paper=a4,
% lädt Sprachpakete
english,ngerman,
]{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
% //////////////////// Pakete laden ////////////////////
\usepackage{amsmath}
% modifiziert amsmath
\usepackage{mathtools}
% mathematische Symbole, für \ceckmarks
\usepackage{amssymb}
% für proof
\usepackage{amsthm}
% für \mathscr
\usepackage{mathrsfs}
\usepackage{latexsym}
% für bessere Worttrennung
\usepackage{microtype}
% Spracheinstellung
\usepackage[ngerman]{babel}
% für Quellcode
\usepackage{verbatim}
\usepackage{listings}
% für Umlaute und Sonderzeichen in der Tex-Datei
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
% für Tabellen mit gleicher Spaltenbreite und automatischen Umbrüchen
\usepackage{tabularx}
\usepackage{fullpage}
% für multirow in tabulars
\usepackage{multirow}
\usepackage{rotate}
% um Farben zu benutzen, kann mehr als das Paket color
\usepackage[cmyk,table]{xcolor}
% Verlinkungen
\usepackage[
% farbige Schrift, statt farbiger Rahmen
colorlinks,
% verlinkt im Abb.Verzeichnis Seitenzahl statt Bildunterschrift
linktocpage,
% setzt Farbe der Links auf blau
linkcolor=blue
]{hyperref}
% nur für digitale Anwendungen, url = "http://www.example.com"
% für Webadressen wie e-mail usw.: "\url{http://www.example.com}"
\usepackage{url}
% für versch. Aufzählungezeichen wie z.B. a)
\usepackage{enumitem}
% folgt ein Leerzeichen nach einem \Befehl, wird es nicht verschluckt
\usepackage{xspace}
% für das Durchstreichen u.a. in Matheformeln mit \cancel
\usepackage{cancel}
% für \forloop und \whiledo
\usepackage{ifthen}
% //////////////////// Syntaxhervorhebung ////////////////////
\lstloadlanguages{Python, Haskell, [LaTeX]TeX, Java}
\lstset{%
% \scriptsize: die Fontgröße für den Quelltext
basicstyle=\footnotesize\ttfamily,
% legt Farbe der Box fest
backgroundcolor = \color{bgcolour},
% automatische Umbrüche nur nach Leerzeichen?
breakatwhitespace=false,
% automatische Zeilenumbrüche?
breaklines=true,
% die Überschrift steht oben, t = top
captionpos=t,
% Formatierung der Kommentare
commentstyle=\color{codeblue}\ttfamily,
% einfacher Rahmen um den Quelltext
frame=single,
% Behalte Leerzeichen im Quelltext. Nützlich, um
% Einrückungen zu erhalten (benötigt eventuell columns=flexible)
keepspaces=true,
% Formatierung der Schlüsselwörter
keywordstyle=\bfseries\ttfamily\color{codepurple},
% Wohin mit den Zeilennummern?
% mögliche Werte sind: none, left, right
numbers=left,
% Formatierung der Zeilennummern
numberstyle=\tiny\color{codegreen},
% Abstand zwischen Zeilennummern und Quelltext
numbersep=5pt,
% nummeriert nur jede i-te Zeile
stepnumber=1,
% Zeige alle Leerzeichen mit Hilfe von speziellen Unterstrichen;
% überschreibt 'showstringspaces'
showspaces=false,
% unterstreiche Leerzeichen nur in Zeichenketten
showstringspaces=false,
% Zeige Tabulatoren in Zeichenketten mit Hilfe von speziellen
% Unterstrichen
showtabs=false,
flexiblecolumns=false,
% Schrittweite zwischen Zeilennummern.
% Der Wert 1 bedeutet, dass jede Zeile nummeriert wird.
tabsize=1,
% Formatierung der Zeichenketten.
stringstyle=\color{orange}\ttfamily,
% leere Zeilen werden nicht nummeriert
numberblanklines=false,
% Abstand zum linken Seitenrand
xleftmargin=1.2em,
% Abstand zum rechten Seitenrand
xrightmargin=0.4em,
aboveskip=2ex,
}
\lstdefinestyle{py}{%
language=Python,
}
\lstdefinestyle{hs}{%
language=Haskell,
}
\lstdefinestyle{tex}{%
language=[LaTeX]TeX,
% Um LaTex im Quelltext einzufügen
escapeinside={\%*}{*)},
% Hervorhebung der TeX-Schlüsselwörter
texcsstyle=*\bfseries\color{blue},
morekeywords={*,$,\{,\},\[,\],lstinputlisting,includegraphics,
rowcolor,columncolor,listoffigures,lstlistoflistings,
subsection,subsubsection,textcolor,tableofcontents,colorbox,
fcolorbox,definecolor,cellcolor,url,linktocpage,subtitle,
subject,maketitle,usetikzlibrary,node,path,addbibresource,
printbibliography},
numbers=none,
numbersep=0pt,
xleftmargin=0.4em,
}
\lstdefinestyle{java}{%
language=Java,
extendedchars=true,
}
% füge einen x64-Assembler Dialekt hinzu
\lstdefinelanguage[x64]{Assembler}
% basiert auf dem "x86masm" Dialekt
[x86masm]{Assembler}
% zusätzliche Schlüsselwörter
{morekeywords={CDQE,CQO,CMPSQ,CMPXCHG16B,JRCXZ,LODSQ,MOVSXD, %
POPFQ,PUSHFQ,SCASQ,STOSQ,IRETQ,RDTSCP,SWAPGS, %
rax,rdx,rcx,rbx,rsi,rdi,rsp,rbp, %
r8,r8d,r8w,r8b,r9,r9d,r9w,r9b}
}
\lstdefinestyle{c}{
language=c,
extendedchars=true,
}
% //////////////////// eigene Anweisungen ////////////////////
% benötigt package xspace
\newcommand\FU{Freie Universität Berlin\xspace}
\newcommand\gdw{g.\,d.\,w.\xspace}
\newcommand\oBdA{o.\,B.\,d.\,A.\xspace}
\newcommand\N{\mathbb{N}\xspace}
\newcommand\Q{\mathbb{Q}\xspace}
\newcommand\R{\mathbb{R}\xspace}
\newcommand\Z{\mathbb{Z}\xspace}
\newcommand\ohneNull{\ensuremath{\backslash\lbrace 0\rbrace}}% \{0}
% Schreibt Befehl \dh in \dhALT um
\let\dhALT\dh
%renew überschreibt command \dh
\renewcommand\dh{d.\,h.\xspace}
\newcommand{\from}{\ensuremath{\colon}}
\newcommand{\floor}[1]{\lfloor{#1}\rfloor}
\newcommand{\ceil}[1]{\lceil{#1}\rceil}
\newcommand{\abbrev}[2]{\expandafter\newcommand\csname
#1\endcsname{#2\xspace}}
\newcommand{\cclasss}[2]{\abbrev{#1}{\textsf{#2}}}
\newcommand{\cclass}[1]{\cclasss{#1}{#1}}
\cclasss{ccP}{P}
\cclass{NP}
\cclass{LOGSPACE}
\cclass{NL}
% //////////////// mathematische Funktionen ////////////////////
\DeclareMathOperator{\True}{True}
\DeclareMathOperator{\False}{False}
% //////////////////// eigene Theoreme ////////////////////
\newtheorem{theorem}{Satz}
\newtheorem{corollary}[theorem]{Korollar}
\newtheorem{lemma}[theorem]{Lemma}
\newtheorem{observation}[theorem]{Beobachtung}
\newtheorem{definition}[theorem]{Definition}
\newtheorem{Literatur}[theorem]{Literatur}
% konfiguriert proof
\makeatletter
\newenvironment{Proof}[1][\proofname]{\par
\pushQED{\qed}%
\normalfont \topsep6\p@\@plus6\p@\relax
\trivlist
\item[\hskip\labelsep
\bfseries
#1\@addpunct{.}]\ignorespaces
}{%
\popQED\endtrivlist\@endpefalse
}
\makeatother
% //////////////////// eigene Farben ////////////////////
\let\definecolor=\xdefinecolor
\definecolor{FUgreen}{RGB}{153,204,0}
\definecolor{FUblue}{RGB}{0,51,102}
\definecolor{middlegray}{rgb}{0.5,0.5,0.5}
\definecolor{lightgray}{rgb}{0.8,0.8,0.8}
\definecolor{orange}{rgb}{0.8,0.3,0.3}
\definecolor{azur}{rgb}{0,0.7,1}
\definecolor{yac}{rgb}{0.6,0.6,0.1}
\definecolor{Pink}{rgb}{1,0,0.6}
\definecolor{bgcolour}{rgb}{0.97,0.97,0.97}
\definecolor{codegreen}{rgb}{0,0.6,0}
\definecolor{codegray}{rgb}{0.35,0.35,0.35}
\definecolor{codepurple}{rgb}{0.58,0,0.82}
\definecolor{codeblue}{rgb}{0.4,0.5,1}
% //////////////////// eigene Einstellungen ////////////////////
% verhindert Einrückung der 1. Zeile eines Absatzes
\parindent 0pt
% <-- Nummer des Übungszettels
\newcommand{\ubungNo}{10}
% <-- Name der Lehrveranstaltung eintragen
\newcommand{\veranstaltung}{Functional Programming}
% <-- z.B. SoSo 17, WiSe 17/18
\newcommand{\semester}{WiSe 23/24}
% % <-- Hier Anzahl der Aufgaben eintragen
\newcommand{\aufgNo}{3}
% https://tex.stackexchange.com/a/117538
\renewcommand\lstlistingname{Example}
\usepackage{tikz}
% /////////////////////// BEGIN DOKUMENT /////////////////////////
\begin{document}
\setkomafont{section}{\large}
% ////////////// Daten //////////////
\begin{center}
{\veranstaltung, \semester}\par
{\Large Tutorial Tasks \ubungNo}\par
\end{center}
\vspace{-3ex} % Abstand
\rule{\linewidth}{0.8pt} % horizontale Linie
\vspace{-3ex} % Abstand
% /////////////////////// Aufgabe 1 /////////////////////////
%alter Zettel 8 Bäume zeichnen
%einfügen löschen, kleinstes Elem
\section*{Task 1: Perform algorithms by hand}
\begin{enumerate}
\item Rewrite the following equations in reverse Polish notation and solve by hand:
\begin{enumerate}[label=(\roman*)]
\item $(9-3) + \log (8)$
\item $(10/4) - \sqrt{ 4 }$
\end{enumerate}
\item Use the algorithm from the lecture to check by hand whether \texttt{[]([({}) []])} and \texttt{[][()){}]} are valid bracket expressions.
\end{enumerate}
\section*{Aufgabe 2: Module}
\begin{enumerate}
\item Create a module \lstinline{Queue} that exports the algebraic data type \lstinline{Queue} and the functions \lstinline{isEmpty}, \lstinline{dequeue} and \lstinline{enqueue}. \par
The functions in question are attached below, otherwise the example from the live code of the lecture (\lstinline{FQueue}) should be used.\par
Add the functions
\begin{enumerate}[label= (\roman*)]
\item \lstinline{hasElem :: Queuelike a => b -> a b -> Bool} (checks whether the passed value is contained in the \lstinline{Queue})
\item \lstinline{count :: Queuelike a => b -> a b -> Int} (counts how often the passed value is contained in the \lstinline{queue})
\end{enumerate}
and export them.
\begin{lstlisting}[language=Haskell]
-- Type class for Queues
class Queuelike s where
enqueue :: a -> s a -> s a
dequeue :: s a -> Maybe (a, s a)
isEmpty :: s a -> Bool
data Queue a = Q [a] [a] deriving Show
--(Q inp out) the first list is used for inserting elements, the second one for removing.
instance Queuelike Queue where
enqueue x (Q inp out ) = Q (x:inp) out
dequeue (Q [] []) = Nothing
dequeue (Q inp []) = dequeue (Q [] (reverse inp))
dequeue (Q inp (x:out)) = Just (x, Q inp out)
isEmpty (Q [] []) = True
isEmpty _ = False
\end{lstlisting}
\newpage
\item Import the module into a new Haskell file and write the following functions that simulate a checkout queue in a shop.
In the queue, you queue people with shopping trolleys. Each shopping trolley contains different products with assigned prices.
\begin{enumerate}[label= (\roman*)]
\item Write suitable type synonyms or algebraic data types that represent a shopping trolley and the queue of shopping trolleys.
\item Write a function \lstinline{anstellen} in which a shopping trolley is added to the checkout queue.
\item Write a function \lstinline{cash} that determines the total price of the goods for the shopping trolley that was queued first.
The return of \lstinline{kassieren} should be a tuple of the total price and the new checkout queue.
\end{enumerate}
\end{enumerate}
% /////////////////////// END DOKUMENT /////////////////////////
\end{document}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment