Binary file pre_solution1/collatz.jar has changed
--- a/pre_solution1/collatz.scala Fri Nov 06 01:07:26 2020 +0000
+++ b/pre_solution1/collatz.scala Sat Nov 07 19:13:06 2020 +0000
@@ -42,7 +42,7 @@
//for (i <- 130 to 10000) println(s"$i: ${last_odd(i)}")
-for (i <- 1 to 100) println(s"$i: ${collatz(i)}")
+//for (i <- 1 to 100) println(s"$i: ${collatz(i)}")
}
Binary file pre_templates1/collatz.jar has changed
--- a/progs/hello-world.scala Fri Nov 06 01:07:26 2020 +0000
+++ b/progs/hello-world.scala Sat Nov 07 19:13:06 2020 +0000
@@ -1,14 +1,3 @@
-object Hello //extends App
-{
- var x = 1
-
- println("test")
-
- x = x + 2
-
- println("foo")
-
- synchronized { x = x + 1 }
-
+object Hello extends App {
println("hello world")
}
--- a/progs/lecture1.scala Fri Nov 06 01:07:26 2020 +0000
+++ b/progs/lecture1.scala Sat Nov 07 19:13:06 2020 +0000
@@ -1,21 +1,21 @@
// Scala Lecture 1
//=================
+
// Value assignments
// (their names should be lower case)
//====================================
+val x = 42
+val y = 3 + 4
+val z = x / y
+val x = 70
+print(z)
+
+// (you cannot reassign values: z = 9 will give an error)
//var z = 9
//z = 10
-val x = 42
-val y = 3 + 4
-val z = x / y
-val x = 70
-
-// (you cannot reassign values: z = 9 will give an error)
-
-
// Hello World
//=============
@@ -92,14 +92,11 @@
val lst = List(1,2,3,1)
-
println(lst.toString)
println(lst.mkString)
println(lst.mkString(","))
-println(lst.mkString(", "))
-
// some methods take more than one argument
println(lst.mkString("{", ",", "}"))
--- a/progs/mandelbrot.scala Fri Nov 06 01:07:26 2020 +0000
+++ b/progs/mandelbrot.scala Sat Nov 07 19:13:06 2020 +0000
@@ -90,7 +90,7 @@
// but might leave early when the pred is satisfied
def iterations(c: Complex, max: Int) : Int = {
def next(z: Complex) = z * z + c
- def pred(z: Complex) = z.abs < 2 // exit condition
+ def pred(z: Complex) = z.abs() < 2 // exit condition
LazyList.iterate(0.0 * i, max)(next).takeWhile(pred).size
}
@@ -133,6 +133,7 @@
}
+
// example 1
val exa1 = -2.0 + -1.5 * i
val exa2 = 1.0 + 1.5 * i
@@ -157,12 +158,10 @@
val delta = (exc2 - exc1) * 0.0333
-/*
println(s"${time_needed(
for (n <- (0 to 12))
mandelbrot(exc1 + delta * n,
exc2 - delta * n, 100))} secs")
-*/
Binary file slides/slides01.pdf has changed
--- a/slides/slides01.tex Fri Nov 06 01:07:26 2020 +0000
+++ b/slides/slides01.tex Sat Nov 07 19:13:06 2020 +0000
@@ -17,6 +17,41 @@
numbers=none,
xleftmargin=0mm}
+
+\colorlet{punct}{red!60!black}
+\definecolor{background}{HTML}{EEEEEE}
+\definecolor{delim}{RGB}{20,105,176}
+\colorlet{numb}{magenta!60!black}
+
+\lstdefinelanguage{json}{
+ basicstyle=\normalfont\ttfamily,
+ numbers=left,
+ numberstyle=\scriptsize,
+ stepnumber=1,
+ %numbersep=8pt,
+ showstringspaces=false,
+ breaklines=true,
+ %frame=lines,
+ %backgroundcolor=\color{background},
+ literate=
+ *{0}{{{\color{numb}0}}}{1}
+ {1}{{{\color{numb}1}}}{1}
+ {2}{{{\color{numb}2}}}{1}
+ {3}{{{\color{numb}3}}}{1}
+ {4}{{{\color{numb}4}}}{1}
+ {5}{{{\color{numb}5}}}{1}
+ {6}{{{\color{numb}6}}}{1}
+ {7}{{{\color{numb}7}}}{1}
+ {8}{{{\color{numb}8}}}{1}
+ {9}{{{\color{numb}9}}}{1}
+ {:}{{{\color{punct}{:}}}}{1}
+ {,}{{{\color{punct}{,}}}}{1}
+ {\{}{{{\color{delim}{\{}}}}{1}
+ {\}}{{{\color{delim}{\}}}}}{1}
+ {[}{{{\color{delim}{[}}}}{1}
+ {]}{{{\color{delim}{]}}}}{1},
+}
+
\newcommand{\bl}[1]{\textcolor{blue}{#1}}
\newcommand{\RIGHTarrow}[3]{%
@@ -72,10 +107,10 @@
\begin{center}
\begin{tabular}{ll}
Email: & christian.urban at kcl.ac.uk\\
- Office: & N\liningnums{7.07} (North Wing, Bush House)\bigskip\\
+ %Office: & N\liningnums{7.07} (North Wing, Bush House)\bigskip\\
Slides \& Code: & KEATS\bigskip\\
- Office Hours: & Thursdays 12:00 -- 14:00\\
- Additionally: & (for Scala) Tuesdays 10:45 -- 11:45\\
+ %Office Hours: & Thursdays 12:00 -- 14:00\\
+ %Additionally: & (for Scala) Tuesdays 10:45 -- 11:45\\
\end{tabular}
\end{center}
@@ -207,6 +242,29 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\begin{frame}[c, fragile]
+
+\small
+My personal keboard shortcut for VS Code\\
+(in keybindings.json)\bigskip
+
+\tiny
+\begin{lstlisting}[language=json,numbers=none]
+[
+ {
+ "key": "ctrl+enter",
+ "command": "workbench.action.terminal.runSelectedText",
+ "when": "editorTextFocus && editorHasSelection"
+ }
+]
+\end{lstlisting}
+
+
+\end{frame}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[t]
\frametitle{Why Scala?}
@@ -219,7 +277,7 @@
\multicolumn{2}{r@{}}{\footnotesize$^*$ source: Stackoverflow Developer Survey, 2019}
\end{tabular}
\end{center}
-\RIGHTarrow{2}{2.4}{6.4}
+\RIGHTarrow{2}{2.0}{6.3}
\DOWNarrow{2}{10.1}{4.4}
}