updated
authorChristian Urban <christian.urban@kcl.ac.uk>
Mon, 09 Nov 2020 14:34:12 +0000
changeset 356 d1046d9d3213
parent 355 bc3980949af2
child 357 826a8dbb658c
updated
cws/main_cw01.tex
cws/main_cw02.tex
cws/main_cw03.tex
cws/main_cw04.tex
cws/main_cw05.tex
cws/pre_cw01.pdf
cws/pre_cw01.tex
cws/pre_cw02.tex
cws/pre_cw03.tex
pre_testing1/collatz_test.sh
progs/lecture1.scala
slides/slides01.tex
slides/slides02.pdf
--- a/cws/main_cw01.tex	Sun Nov 08 13:09:38 2020 +0000
+++ b/cws/main_cw01.tex	Mon Nov 09 14:34:12 2020 +0000
@@ -8,7 +8,7 @@
 
 \begin{document}
 
-\section*{Core Part 6 (Scala, 7 Marks)}
+\section*{Main Part 1 (Scala, 7 Marks)}
 
 \IMPORTANT{This part is about Scala. It is due on \cwSIXa{} at 5pm and worth 7\%.}
 
@@ -45,7 +45,7 @@
 \subsection*{Hints}
 
 \noindent
-\textbf{For the Core Part:} useful string functions:
+\textbf{For the Main Part:} useful string functions:
 \texttt{.startsWith(...)} for checking whether a string has a given
 prefix, \texttt{\_ ++ \_} for concatenating two strings; useful option
 functions: \texttt{.flatten} flattens a list of options such that it
@@ -64,7 +64,7 @@
 \texttt{100.0 / 3}!
 
 \newpage
-\subsection*{Core Part (7 Marks, file drumb.scala)}
+\subsection*{Main Part (7 Marks, file drumb.scala)}
 
 A purely fictional character named Mr T.~Drumb inherited in 1978
 approximately 200 Million Dollar from his father. Mr Drumb prides
--- a/cws/main_cw02.tex	Sun Nov 08 13:09:38 2020 +0000
+++ b/cws/main_cw02.tex	Mon Nov 09 14:34:12 2020 +0000
@@ -9,7 +9,7 @@
 
 %% should ask to lower case the words.
 
-\section*{Part 7 (Scala, 7 Marks)}
+\section*{Main Part 2 (Scala, 7 Marks)}
 
 
 \noindent
@@ -70,7 +70,7 @@
 \newpage
 
 
-\subsection*{Part (7 Marks, file danube.scala)}
+\subsection*{Main Part 2 (7 Marks, file danube.scala)}
 
 You are creating Danube.co.uk which you hope will be the next big thing
 in online movie renting. You know that you can save money by
--- a/cws/main_cw03.tex	Sun Nov 08 13:09:38 2020 +0000
+++ b/cws/main_cw03.tex	Mon Nov 09 14:34:12 2020 +0000
@@ -119,7 +119,7 @@
 % BF IDE
 % https://www.microsoft.com/en-us/p/brainf-ck/9nblgggzhvq5
   
-\section*{Part 8 (Scala, 7 Marks)}
+\section*{Main Part 3 (Scala, 7 Marks)}
 
 %\mbox{}\hfill\textit{``[Google’s MapReduce] abstraction is inspired by the}\\
 %\mbox{}\hfill\textit{map and reduce primitives present in Lisp and many}\\
--- a/cws/main_cw04.tex	Sun Nov 08 13:09:38 2020 +0000
+++ b/cws/main_cw04.tex	Mon Nov 09 14:34:12 2020 +0000
@@ -18,7 +18,7 @@
 
 \mbox{}\\[-18mm]\mbox{}
 
-\section*{Preliminary and Core Part 9 (Scala, 4 + 6 Marks)}
+\section*{Preliminary and Main Part 4 (Scala, 4 + 6 Marks)}
 
 \mbox{}\hfill\textit{``The problem with object-oriented languages is they’ve got all this implicit,}\\
 \mbox{}\hfill\textit{environment that they carry around with them. You wanted a banana but}\\
@@ -206,7 +206,7 @@
 
 
 \noindent
-\textbf{Core Part} a useful list function: \texttt{.sortBy} sorts a list
+\textbf{Main Part} a useful list function: \texttt{.sortBy} sorts a list
 according to a component given by the function; a function can be
 tested to be tail-recursive by annotation \texttt{@tailrec}, which is
 made available by importing \texttt{scala.annotation.tailrec}.\medskip
--- a/cws/main_cw05.tex	Sun Nov 08 13:09:38 2020 +0000
+++ b/cws/main_cw05.tex	Mon Nov 09 14:34:12 2020 +0000
@@ -15,7 +15,7 @@
 
 \begin{document}
 
-\section*{Part 10 (Scala, 10 Marks)}
+\section*{Part 5 (Scala, 10 Marks)}
 
 \mbox{}\hfill\textit{``If there's one feature that makes Scala, `Scala',}\\
 \mbox{}\hfill\textit{ I would pick implicits.''}\smallskip\\
Binary file cws/pre_cw01.pdf has changed
--- a/cws/pre_cw01.tex	Sun Nov 08 13:09:38 2020 +0000
+++ b/cws/pre_cw01.tex	Mon Nov 09 14:34:12 2020 +0000
@@ -8,7 +8,7 @@
 
 \begin{document}
 
-\section*{Preliminary Part 6 (Scala, 3 Marks)}
+\section*{Preliminary Part 1 (Scala, 3 Marks)}
 
 \mbox{}\hfill\textit{``The most effective debugging tool is still careful thought,}\\
 \mbox{}\hfill\textit{coupled with judiciously placed print statements.''}\smallskip\\
--- a/cws/pre_cw02.tex	Sun Nov 08 13:09:38 2020 +0000
+++ b/cws/pre_cw02.tex	Mon Nov 09 14:34:12 2020 +0000
@@ -9,7 +9,7 @@
 
 %% should ask to lower case the words.
 
-\section*{Preliminary Part 7 (Scala, 3 Marks)}
+\section*{Preliminary Part 2 (Scala, 3 Marks)}
 
 \mbox{}\hfill\textit{``What one programmer can do in one month,}\\
 \mbox{}\hfill\textit{two programmers can do in two months.''}\smallskip\\
--- a/cws/pre_cw03.tex	Sun Nov 08 13:09:38 2020 +0000
+++ b/cws/pre_cw03.tex	Mon Nov 09 14:34:12 2020 +0000
@@ -16,7 +16,7 @@
 % BF IDE
 % https://www.microsoft.com/en-us/p/brainf-ck/9nblgggzhvq5
   
-\section*{Preliminary Part 8 (Scala, 3 Marks)}
+\section*{Preliminary Part 3 (Scala, 3 Marks)}
 
 \mbox{}\hfill\textit{``[Google’s MapReduce] abstraction is inspired by the}\\
 \mbox{}\hfill\textit{map and reduce primitives present in Lisp and many}\\
--- a/pre_testing1/collatz_test.sh	Sun Nov 08 13:09:38 2020 +0000
+++ b/pre_testing1/collatz_test.sh	Mon Nov 09 14:34:12 2020 +0000
@@ -7,6 +7,7 @@
 out=${1:-output}
 
 echo -e "" > $out
+echo -e "" > c$out
 
 echo -e "Below is the feedback for your submission collatz.scala" >> $out
 echo -e "" >> $out
@@ -15,7 +16,7 @@
 # compilation tests
 
 function scala_compile {
-  (ulimit -t 30; JAVA_OPTS="-Xmx1g" scala -Xprint:parser "$1" 2> c$out 1> c$out)
+  (ulimit -t 30; JAVA_OPTS="-Xmx1g" scala -Xprint:parser "$1" 2>> $out 1>> $out)
 }
 
 # functional tests
@@ -48,10 +49,11 @@
 
 # var, .par return, ListBuffer test
 #
-echo -e "collatz.scala does not contain VARS, RETURNS etc?" >> $out
 
 if  [ $tsts -eq 0 ]
-then 
+then
+   echo -e "collatz.scala does not contain VARS, RETURNS etc?" >> $out
+    
    if (scala_vars collatz.scala)
    then
       echo -e "  --> FAIL (make triple-sure your program conforms to the required format)\n" >> $out
--- a/progs/lecture1.scala	Sun Nov 08 13:09:38 2020 +0000
+++ b/progs/lecture1.scala	Mon Nov 09 14:34:12 2020 +0000
@@ -41,6 +41,27 @@
 List(1,2,3,1)
 Set(1,2,3,1)
 
+// picking an element in a list
+val lst = List(1, 2, 3, 1)
+
+lst(0)
+lst(2)
+
+// head and tail
+lst.head
+lst.tail
+
+// some alterative syntax for lists
+
+Nil     // empty list
+
+1 :: 2 :: 3 :: Nil
+List(1, 2, 3) ::: List(4, 5, 6)
+
+// also
+List(1, 2, 3) ++ List(3, 6, 5)
+Set(1, 2, 3) ++ Set(3, 6, 5)
+
 // ranges
 1 to 10
 (1 to 10).toList
@@ -48,23 +69,10 @@
 
 (1 until 10).toList
 
-// picking an element in a list
-val lst = List(1, 2, 3, 1)
-lst(0)
-lst(2)
-
-// some alterative syntax for lists
-
-1 :: 2 :: 3 :: Nil
-List(1, 2, 3) ::: List(4, 5, 6)
-
-// also
-List(1, 2, 3) ++ List(4, 5, 6)
-
 
 // Equality in Scala is structural
 //=================================
-val a = "Dave"
+val a = "Dave2"
 val b = "Dave"
 
 if (a == b) println("Equal") else println("Unequal")
@@ -113,15 +121,18 @@
 List(1,2,3,1).toSet
 
 "hello".toList
-"hello".toList.tail
+"hello".toSet
 
 
 1.toDouble
 
-1L  // a long
-1F  // a float
+1   // an Int
+1L  // a Long
+1F  // a Float
+1D  // a Double
 
-// useful list methods
+// useful list methods on lists
+//==============================
 
 List(1,2,3,4).length
 List(1,2,3,4).reverse
@@ -164,7 +175,7 @@
 
 
 // you can make the type of a value explicit
-val name: String = "leo"
+val name = "bob"
 
 
 // type errors
@@ -195,14 +206,6 @@
 // Function Definitions
 //======================
 
-def foo(s: String) : String = {
-  val tmp = s ++ s ++ s
-  val res = s ++ s
-  res
-}
-
-
-foo("test")
 
 def incr(x: Int) : Int = x + 1
 def double(x: Int) : Int = x + x
@@ -210,6 +213,7 @@
 
 def str(x: Int) : String = x.toString
 
+
 incr(3)
 double(4)
 square(6)
@@ -224,16 +228,6 @@
 //  }
 
 
-// BTW: no returns!!
-// "last" line (expression) in a function determines the 
-// result
-
-
-def silly(n: Int) : Int = {
-  if (n < 10) n * n
-  else n + n
-}
-
 
 // If-Conditionals
 //=================
@@ -280,6 +274,9 @@
 
 power(5, 5)
 
+// BTW: no returns!!
+// "last" line (expression) in a function determines the 
+// result
 
 
 // For-Comprehensions (not For-Loops)
--- a/slides/slides01.tex	Sun Nov 08 13:09:38 2020 +0000
+++ b/slides/slides01.tex	Mon Nov 09 14:34:12 2020 +0000
@@ -605,46 +605,66 @@
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-\begin{frame}[c]
-  \frametitle{Coursework Dates}
+\begin{frame}[c, fragile]
+
+{\Large Why bother? or\smallskip\\\hfill What is wrong with this?}\bigskip\bigskip
+
   
-Similar to C++:\bigskip
+\begin{lstlisting}[language=C,numbers=none]
+for (int i = 10; i < 20; i++) {
+    
+  //...Do something interesting
+  //   with i...
+
+}
+\end{lstlisting}
+
+  
+\end{frame}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
 
-\begin{itemize}
-  \item Preliminary Parts: Wednesdays 4pm
-    \begin{itemize}
-      \item Preliminary Part 6: 3\% (13 November)
-      \item Preliminary Part 7: 4\% (20 November)
-      \item Preliminary Part 8: 4\% (27 November)
-      \item Preliminary Part 9: 4\% (5 December) 
-    \end{itemize}\medskip    
-  \item Core Part: 35\% (15 January 2020)\bigskip 
-\end{itemize}
-\end{frame}
-  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%\begin{frame}[c]
+%  \frametitle{Coursework Dates}
+%  
+%Similar to C++:\bigskip
+%
+%\begin{itemize}
+%  \item Preliminary Parts: Wednesdays 4pm
+%    \begin{itemize}
+%      \item Preliminary Part 6: 3\% (13 November)
+%      \item Preliminary Part 7: 4\% (20 November)
+%      \item Preliminary Part 8: 4\% (27 November)
+%      \item Preliminary Part 9: 4\% (5 December) 
+%    \end{itemize}\medskip    
+%  \item Core Part: 35\% (15 January 2020)\bigskip 
+%\end{itemize}
+%\end{frame}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   
 
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-\begin{frame}[c]
-\frametitle{Coursework}
-
-\begin{itemize}
-\item Sorry, I might have been a bit wordy:\\
-  Part 6 of CW description is 7 pages, but
-  I only needed \mbox{< 100} loc for \emph{all} Part 6.\bigskip
-
-\item there is feedback when pushing code to github\medskip
-
-\item there are \texttt{jar}-files you can use to test 
-  my reference implementation\bigskip
-  
-\item we want you to learn FP!\smallskip\\ \alert{\bf no vars}, no mutable
-  data-structures\\ \quad{}e.g.~no \texttt{Arrays}, no \texttt{ListBuffer}
-\end{itemize}
-
-\LEFTarrow{1}{11}{11.8}
-\end{frame}
+%\begin{frame}[c]
+%\frametitle{Coursework}
+%
+%\begin{itemize}
+%\item Sorry, I might have been a bit wordy:\\
+%  Part 6 of CW description is 7 pages, but
+%  I only needed \mbox{< 100} loc for \emph{all} Part 6.\bigskip
+%
+%\item there is feedback when pushing code to github\medskip
+%
+%\item there are \texttt{jar}-files you can use to test 
+%  my reference implementation\bigskip
+%  
+%\item we want you to learn FP!\smallskip\\ \alert{\bf no vars}, no mutable
+%  data-structures\\ \quad{}e.g.~no \texttt{Arrays}, no \texttt{ListBuffer}
+%\end{itemize}
+%
+%\LEFTarrow{1}{11}{11.8}
+%\end{frame}
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%     
@@ -849,34 +869,34 @@
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-\begin{frame}[c]
-\frametitle{\begin{tabular}{c}\\[0cm]\alert{Questions?}\end{tabular}}
-
-\begin{center}
-  \begin{tabular}[t]{@{}l@{}l@{}}
-    \includegraphics[scale=0.1]{../pics/mand4.png} & \hspace{4mm}
-    \raisebox{0mm}{\includegraphics[scale=0.1]{../pics/mand3.png}}      
-  \end{tabular}     
-\end{center}
-
-\begin{center}
-  My Office Hours: Thursdays 12 -- 14\\
-  And specifically for Scala: Tuesdays 10:45 -- 11:45
-\end{center}
-\end{frame}
+%\begin{frame}[c]
+%\frametitle{\begin{tabular}{c}\\[0cm]\alert{Questions?}\end{tabular}}
+%
+%\begin{center}
+%  \begin{tabular}[t]{@{}l@{}l@{}}
+%    \includegraphics[scale=0.1]{../pics/mand4.png} & \hspace{4mm}
+%    \raisebox{0mm}{\includegraphics[scale=0.1]{../pics/mand3.png}}      
+%  \end{tabular}     
+%\end{center}
+%
+%\begin{center}
+%  My Office Hours: Thursdays 12 -- 14\\
+%  And specifically for Scala: Tuesdays 10:45 -- 11:45
+%\end{center}
+%\end{frame}
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-\begin{frame}[t]
-
-\begin{center}  
-\includegraphics[scale=0.4]{../pics/blow.png}
-\end{center}
-
-\begin{textblock}{14}(2,12.4)
-\Large\bf{}Mind-Blowing\\ Programming Languages: C/C++
-\end{textblock}
-\end{frame}
+%\begin{frame}[t]%
+%
+%\begin{center}  
+%\includegraphics[scale=0.4]{../pics/blow.png}
+%\end{center}
+%
+%\begin{textblock}{14}(2,12.4)
+%\Large\bf{}Mind-Blowing\\ Programming Languages: C/C++
+%\end{textblock}
+%\end{frame}
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   
 
Binary file slides/slides02.pdf has changed