haskell-lectures/VL1/content/VL1_functions_and_control_s...

21 lines
1.0 KiB
TeX

\ifger{Schreiben wir unsere erste Funktion. Wir wollen etwas wie die folgende mathematische Funktion:}{Let's make our first function. We want something like the following mathematical function}\\
$f(x) = x * x$
\vspace{\baselineskip}
\\
\ifger{Wie könnte der Haskell code aussehen?}{How could the haskell code look like?}
\pause
\ifger{Beinahe genauso:}{Almost the same:}
\begin{haskellcode}
f x = x * x
\end{haskellcode}
\vspace{\baselineskip}
GHCi...
\pause
\vspace{\baselineskip}
\\
\ifger{Was ist eine mögliche Typsignatur dieser Funktion?}{What is a possible type signature for this function?}
\begin{haskellcode}
f :: Int -> Int
f x = x * x
\end{haskellcode}
\ifger{Also, die Funktion bekommt einen \hinline{Int} als Eingabe und gibt einen \hinline{Int} als Ausgabe zurück. Lasst Euch nicht von}{So the function gets an \hinline{Int} and returns an \hinline{Int}. Don't get confused by} \hinline{->} \ifger{verwirren.}{.} \ifger{Seht es einfach als Symbol zum Trennen von Eingabe und Ausgabe}{Just think of it as a symbol for separating input and output}.