14 \section*{Scala 3 in 6CCS3CFL} |
14 \section*{Scala 3 in 6CCS3CFL} |
15 |
15 |
16 For the coursework in this module you are free to use any programming |
16 For the coursework in this module you are free to use any programming |
17 language you like, but I will show you all my code using Scala---I |
17 language you like, but I will show you all my code using Scala---I |
18 hope you have fond memories of Scala from PEP. The only difference |
18 hope you have fond memories of Scala from PEP. The only difference |
19 with PEP is that I will use the current |
19 with PEP is that I will the Ammonite REPL for Scala 3. |
20 stable version of Scala, which at the time of writing is Scala 3.3.1. |
|
21 |
20 |
22 \begin{tcolorbox}[colback=red!5!white,colframe=red!75!black] |
21 \begin{tcolorbox}[colback=red!5!white,colframe=red!75!black] |
23 If you intend to submit your code for the CW in Scala, you \underline{MUST} submit code that |
22 If you intend to submit your code for the CW in Scala, you \underline{MUST} submit code that |
24 is compatible with Scala 3!! This is to make it easier for me to test |
23 is compatible with Scala 3!! This is to make it easier for me to test |
25 your code and the changes between Scala 2 from last year PEP to Scala |
24 your code and the changes between Scala 2 from last year PEP to Scala |
49 works very similarly, for example |
48 works very similarly, for example |
50 |
49 |
51 \begin{lstlisting}[language={},numbers=none,basicstyle=\ttfamily\small] |
50 \begin{lstlisting}[language={},numbers=none,basicstyle=\ttfamily\small] |
52 $ amm |
51 $ amm |
53 Loading... |
52 Loading... |
54 Welcome to the Ammonite Repl 2.5.9 (Scala 3.2.2 Java 17.0.7) |
53 Welcome to the Ammonite Repl 3.0.0-M2 (Scala 3.3.3 Java 21.0.4) |
55 scala> 1 + 2 |
54 @ 1 + 2 |
56 res0: Int = 3 |
55 res0: Int = 3 |
57 \end{lstlisting} %% $ |
56 \end{lstlisting} %% $ |
58 |
57 |
59 %%\runExtCmd[redirect]{ls -la}{voss} |
58 %%\runExtCmd[redirect]{ls -la}{voss} |
60 |
59 |
66 a Unix-like system, a sure way to install the right version of Ammonite |
65 a Unix-like system, a sure way to install the right version of Ammonite |
67 is by using \texttt{curl}: |
66 is by using \texttt{curl}: |
68 |
67 |
69 \begin{lstlisting}[numbers=none,language={},basicstyle=\ttfamily\small] |
68 \begin{lstlisting}[numbers=none,language={},basicstyle=\ttfamily\small] |
70 $ curl -L https://github.com/com-lihaoyi/Ammonite/releases/\ |
69 $ curl -L https://github.com/com-lihaoyi/Ammonite/releases/\ |
71 download/2.5.9/3.2-2.5.9 --output amm |
70 download/3.0.0-M2/3.3-3.0.0-M2 --output amm |
72 \end{lstlisting} %% $ |
71 \end{lstlisting} %% $ |
73 |
72 |
74 \noindent |
73 \noindent |
75 This creates a file \code{amm} which before it can be run might |
74 This creates a file \code{amm} which before it can be run might |
76 need some adjustments of the permissions. Under recent versions of |
75 need some adjustments of the permissions. Under recent versions of |
77 Windows also have \texttt{curl}, but need a slightly different call: |
76 Windows also have \texttt{curl}, but need a slightly different call: |
78 |
77 |
79 \begin{lstlisting}[numbers=none,language={},basicstyle=\ttfamily\small] |
78 \begin{lstlisting}[numbers=none,language={},basicstyle=\ttfamily\small] |
80 $ curl -L https://github.com/com-lihaoyi/Ammonite/releases/\ |
79 $ curl -L https://github.com/com-lihaoyi/Ammonite/releases/\ |
81 download/2.5.9/3.2-2.5.9 --output amm.bat |
80 download/3.0.0-M2/3.3-3.0.0-M2 --output amm.bat |
82 \end{lstlisting} %% $ |
81 \end{lstlisting} %% $ |
83 |
82 |
84 \noindent |
83 \noindent |
85 Then you need to run Ammonite with \texttt{.$\backslash$amm} and there |
84 Then you need to run Ammonite with \texttt{.$\backslash$amm} and there |
86 is no need to change any permissions under Windows. |
85 is no need to change any permissions under Windows. |