5 |
5 |
6 %cheat sheet |
6 %cheat sheet |
7 %http://worldline.github.io/scala-cheatsheet/ |
7 %http://worldline.github.io/scala-cheatsheet/ |
8 |
8 |
9 \begin{document} |
9 \begin{document} |
10 \fnote{\copyright{} Christian Urban, King's College London, 2020} |
10 \fnote{\copyright{} Christian Urban, King's College London, 2020, 2021} |
11 |
11 |
12 \section*{Scala in 6CCS3CFL} |
12 \section*{Scala in 6CCS3CFL} |
13 |
13 |
14 For the coursework in this module you are free to use any programming |
14 For the coursework in this module you are free to use any programming |
15 language you like, but I will show you all my code using Scala---I |
15 language you like, but I will show you all my code using Scala---I |
41 works very similarly, for example |
41 works very similarly, for example |
42 |
42 |
43 \begin{lstlisting}[language={},numbers=none,basicstyle=\ttfamily\small] |
43 \begin{lstlisting}[language={},numbers=none,basicstyle=\ttfamily\small] |
44 $ amm |
44 $ amm |
45 Loading... |
45 Loading... |
46 Welcome to the Ammonite Repl 2.3.8 (Scala 2.13.3 Java 9) |
46 Welcome to the Ammonite Repl 2.4.0 (Scala 2.13.6 Java 9) |
47 scala> 1 + 2 |
47 scala> 1 + 2 |
48 res0: Int = 3 |
48 res0: Int = 3 |
49 \end{lstlisting} %% $ |
49 \end{lstlisting} %% $ |
50 |
50 |
51 \noindent |
51 \noindent |
52 Ammonite uses the same Scala compiler, just adds some useful features |
52 Ammonite uses the same Scala compiler, just adds some useful features |
53 on top of it. It is quite main-stream in the Scala community and it should |
53 on top of it. It is quite main-stream in the Scala community and it should |
54 therefore be very easy for you to install \texttt{amm}. |
54 therefore be very easy for you to install \texttt{amm}. If you work under |
|
55 a Unix-like system, a sure way to install the right version of Ammonite |
|
56 is by using \texttt{curl}: |
|
57 |
|
58 \begin{lstlisting}[numbers=none,language={},basicstyle=\ttfamily\small] |
|
59 $ curl -L https://github.com/com-lihaoyi/Ammonite/ |
|
60 releases/download/2.4.0/2.13-2.4.0 --output amm |
|
61 \end{lstlisting} |
|
62 |
55 |
63 |
56 The big advantage of Ammonite is that it comes with some additional |
64 The big advantage of Ammonite is that it comes with some additional |
57 libraries already built-in and also allows one to easily break up code |
65 libraries already built-in and also allows one to easily break up code |
58 into smaller modules. For example reading and writing files in |
66 into smaller modules. For example reading and writing files in |
59 Ammonite can be achieved with |
67 Ammonite can be achieved with |