1 \documentclass{article} |
1 \documentclass{article} |
2 \usepackage{charter} |
|
3 \usepackage{hyperref} |
2 \usepackage{hyperref} |
4 \usepackage{amssymb} |
3 \usepackage{amssymb} |
5 \usepackage{amsmath} |
4 \usepackage{amsmath} |
6 \usepackage{listings} |
5 \usepackage{../langs} |
7 \usepackage{xcolor} |
|
8 |
|
9 |
6 |
10 \newcommand{\dn}{\stackrel{\mbox{\scriptsize def}}{=}}% |
7 \newcommand{\dn}{\stackrel{\mbox{\scriptsize def}}{=}}% |
11 \begin{document} |
8 \begin{document} |
12 |
|
13 \definecolor{javared}{rgb}{0.6,0,0} % for strings |
|
14 \definecolor{javagreen}{rgb}{0.25,0.5,0.35} % comments |
|
15 \definecolor{javapurple}{rgb}{0.5,0,0.35} % keywords |
|
16 \definecolor{javadocblue}{rgb}{0.25,0.35,0.75} % javadoc |
|
17 |
|
18 \lstdefinelanguage{scala}{ |
|
19 morekeywords={abstract,case,catch,class,def,% |
|
20 do,else,extends,false,final,finally,% |
|
21 for,if,implicit,import,match,mixin,% |
|
22 new,null,object,override,package,% |
|
23 private,protected,requires,return,sealed,% |
|
24 super,this,throw,trait,true,try, |
|
25 type,val,var,while,with,yield}, |
|
26 otherkeywords={=>,<-,<\%,<:,>:,\#,@}, |
|
27 sensitive=true, |
|
28 morecomment=[l]{//}, |
|
29 morecomment=[n]{/*}{*/}, |
|
30 morestring=[b]", |
|
31 morestring=[b]', |
|
32 morestring=[b]""" |
|
33 } |
|
34 |
|
35 \lstdefinelanguage{while}{ |
|
36 morekeywords={while, if, then. else, read, write, for, upto, do}, |
|
37 otherkeywords={=>,<-,<\%,<:,>:,\#,@}, |
|
38 sensitive=true, |
|
39 morecomment=[l]{//}, |
|
40 morecomment=[n]{/*}{*/}, |
|
41 morestring=[b]", |
|
42 morestring=[b]', |
|
43 morestring=[b]""" |
|
44 } |
|
45 |
|
46 |
|
47 \lstset{language=Scala, |
|
48 basicstyle=\ttfamily, |
|
49 keywordstyle=\color{javapurple}\bfseries, |
|
50 stringstyle=\color{javagreen}, |
|
51 commentstyle=\color{javagreen}, |
|
52 morecomment=[s][\color{javadocblue}]{/**}{*/}, |
|
53 numbers=left, |
|
54 numberstyle=\tiny\color{black}, |
|
55 stepnumber=1, |
|
56 numbersep=10pt, |
|
57 tabsize=2, |
|
58 showspaces=false, |
|
59 showstringspaces=false} |
|
60 |
|
61 |
|
62 |
9 |
63 \section*{Coursework 3} |
10 \section*{Coursework 3} |
64 |
11 |
65 \noindent |
12 \noindent |
66 This coursework is worth 4\% and is due on 13 December at 16:00. You are asked to |
13 This coursework is worth 4\% and is due on 13 December at 16:00. You are asked to |