# HG changeset patch # User Christian Urban # Date 1409738509 -3600 # Node ID 370c0647a9bf3e74ec4972d32688fd529f19a92d # Parent 34e901c529cec7eaa90bb4d83fb84d61cc6767f3 more material diff -r 34e901c529ce -r 370c0647a9bf handouts/ho01.pdf Binary file handouts/ho01.pdf has changed diff -r 34e901c529ce -r 370c0647a9bf handouts/ho01.tex --- a/handouts/ho01.tex Mon Sep 01 18:05:39 2014 +0100 +++ b/handouts/ho01.tex Wed Sep 03 11:01:49 2014 +0100 @@ -1,18 +1,14 @@ \documentclass{article} -\usepackage{hyperref} -\usepackage{amssymb} -\usepackage{amsmath} -\usepackage[T1]{fontenc} +\usepackage{../style} \usepackage{../langs} -\newcommand{\dn}{\stackrel{\mbox{\scriptsize def}}{=}}% \begin{document} \section*{Handout 1} -This course is about the processing of strings. Lets start with what we mean by \emph{strings}. Strings +This module is about the processing of strings. Lets start with what we mean by \emph{strings}. Strings (they are also sometimes referred to as \emph{words}) are lists of characters drawn from an \emph{alphabet}. If nothing else is specified, we usually assume the alphabet consists of just the lower-case letters $a$, $b$, \ldots, $z$. Sometimes, however, we explicitly diff -r 34e901c529ce -r 370c0647a9bf handouts/scala-ho.pdf Binary file handouts/scala-ho.pdf has changed diff -r 34e901c529ce -r 370c0647a9bf handouts/scala-ho.tex --- a/handouts/scala-ho.tex Mon Sep 01 18:05:39 2014 +0100 +++ b/handouts/scala-ho.tex Wed Sep 03 11:01:49 2014 +0100 @@ -604,12 +604,20 @@ \noindent -Since this function returns a pair of integers, its type -needs to be \code{(Int, Int)}. +Since this function returns a pair of integers, its +return type needs to be \code{(Int, Int)}. Incidentally, +this is also the input type of this function. Notice it takes +\emph{two} arguments, namely \code{m} and \code{n}, both +of which are integers. They are ``packaged'' in a pair. +Consequently the complete type of \code{quo_rem} is + +\begin{lstlisting}[language=Scala, numbers=none] +(Int, Int) => (Int, Int) +\end{lstlisting} Another special type-constructor is for functions, written -as the arrow \code{=>}. For example, the type \code{Int => -String} is for a function that takes an integer as argument +as the arrow \code{=>}. For example, the type +\code{Int => String} is for a function that takes an integer as argument and produces a string. A function of this type is for instance @@ -899,6 +907,10 @@ \item \url{https://www.youtube.com/user/ShadowofCatron} \end{itemize} +\noindent There is also a course at Coursera on Functional +Programming Principles in Scala by Martin Odersky, the main +developer of the Scala language. + While I am quite enthusiastic about Scala, I am also happy to admit that it has more than its fair share of faults. The problem seen earlier of having to give an explicit type to @@ -936,6 +948,8 @@ you do not want, stick with the language you are most familiar with. + + \end{document} %%% Local Variables: diff -r 34e901c529ce -r 370c0647a9bf langs.sty --- a/langs.sty Mon Sep 01 18:05:39 2014 +0100 +++ b/langs.sty Wed Sep 03 11:01:49 2014 +0100 @@ -11,7 +11,7 @@ \lstdefinelanguage{Scala}{ - keywords={abstract,case,catch,class,def,% + morekeywords={abstract,case,catch,class,def,% do,else,extends,false,final,finally,% for,if,implicit,import,match,mixin,% new,null,object,override,package,% @@ -51,10 +51,11 @@ showspaces=false, showstringspaces=false, xleftmargin=8mm, - emphstyle=\color{codeblue}\bfseries} + emphstyle=\color{codeblue}\bfseries, + keepspaces} \lstset{language=Scala, style=mystyle} -\newcommand{\code}[1]{{\lstinline!#1!}} +\newcommand{\code}[1]{{\lstinline{#1}}}