handouts/ho05.tex
changeset 217 cd6066f1056a
parent 173 7cfb7a6f7c99
child 292 7ed2a25dd115
equal deleted inserted replaced
216:f5ec7c597c5b 217:cd6066f1056a
     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[T1]{fontenc}
     5 \usepackage[T1]{fontenc}
     7 \usepackage{listings}
       
     8 \usepackage{xcolor}
       
     9 \usepackage{tikz}
     6 \usepackage{tikz}
    10 \usetikzlibrary{arrows}
     7 \usetikzlibrary{arrows}
    11 \usetikzlibrary{automata}
     8 \usetikzlibrary{automata}
    12 \usetikzlibrary{shapes}
     9 \usetikzlibrary{shapes}
    13 \usetikzlibrary{shadows}
    10 \usetikzlibrary{shadows}
    14 \usetikzlibrary{positioning}
    11 \usetikzlibrary{positioning}
    15 \usetikzlibrary{calc}
    12 \usetikzlibrary{calc}
    16 \usetikzlibrary{fit}
    13 \usetikzlibrary{fit}
    17 \usetikzlibrary{backgrounds}
    14 \usetikzlibrary{backgrounds}
    18 \usepackage{fontspec}
    15 \usepackage{../langs}
    19 \setmonofont{Consolas}
       
    20 
    16 
    21 \newcommand{\dn}{\stackrel{\mbox{\scriptsize def}}{=}}%
    17 \newcommand{\dn}{\stackrel{\mbox{\scriptsize def}}{=}}%
    22 
    18 
    23 \definecolor{javared}{rgb}{0.6,0,0} % for strings
       
    24 \definecolor{javagreen}{rgb}{0.25,0.5,0.35} % comments
       
    25 \definecolor{javapurple}{rgb}{0.5,0,0.35} % keywords
       
    26 \definecolor{javadocblue}{rgb}{0.25,0.35,0.75} % javadoc
       
    27   
       
    28 \lstdefinelanguage{scala}{
       
    29   morekeywords={abstract,case,catch,class,def,%
       
    30     do,else,extends,false,final,finally,%
       
    31     for,if,implicit,import,match,mixin,%
       
    32     new,null,object,override,package,%
       
    33     private,protected,requires,return,sealed,%
       
    34     super,this,throw,trait,true,try,%
       
    35     type,val,var,while,with,yield},
       
    36   otherkeywords={=>,<-,<\%,<:,>:,\#,@},
       
    37   sensitive=true,
       
    38   morecomment=[l]{//},
       
    39   morecomment=[n]{/*}{*/},
       
    40   morestring=[b]",
       
    41   morestring=[b]',
       
    42   morestring=[b]"""
       
    43 }
       
    44 
       
    45 \lstdefinelanguage{while}{
       
    46   morekeywords={while, if, then. else, read, write},
       
    47   otherkeywords={=>,<-,<\%,<:,>:,\#,@},
       
    48   sensitive=true,
       
    49   morecomment=[l]{//},
       
    50   morecomment=[n]{/*}{*/},
       
    51   morestring=[b]",
       
    52   morestring=[b]',
       
    53   morestring=[b]"""
       
    54 }
       
    55 
       
    56 
       
    57 \lstset{language=Scala,
       
    58 	basicstyle=\ttfamily,
       
    59 	keywordstyle=\color{javapurple}\bfseries,
       
    60 	stringstyle=\color{javagreen},
       
    61 	commentstyle=\color{javagreen},
       
    62 	morecomment=[s][\color{javadocblue}]{/**}{*/},
       
    63 	numbers=left,
       
    64 	numberstyle=\tiny\color{black},
       
    65 	stepnumber=1,
       
    66 	numbersep=10pt,
       
    67 	tabsize=2,
       
    68 	showspaces=false,
       
    69 	showstringspaces=false}
       
    70 	
    19 	
    71 \newcommand\grid[1]{%
    20 \newcommand\grid[1]{%
    72 \begin{tikzpicture}[baseline=(char.base)]
    21 \begin{tikzpicture}[baseline=(char.base)]
    73   \path[use as bounding box]
    22   \path[use as bounding box]
    74     (0,0) rectangle (1em,1em);
    23     (0,0) rectangle (1em,1em);