378 \begin{frame}[c] |
376 \begin{frame}[c] |
379 |
377 |
380 {\lstset{language=Java}\fontsize{7}{8}\selectfont |
378 {\lstset{language=Java}\fontsize{7}{8}\selectfont |
381 \texttt{\lstinputlisting{URLReader.java}}} |
379 \texttt{\lstinputlisting{URLReader.java}}} |
382 |
380 |
|
381 \end{frame} |
|
382 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
383 |
|
384 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
385 \begin{frame}[c] |
|
386 \frametitle{Coursework} |
|
387 |
|
388 \begin{itemize} |
|
389 \item sorry, I might have been a bit wordy:\\ |
|
390 CW description is 7 pages, but |
|
391 I only needed \mbox{< 100} loc for all the CW\bigskip |
|
392 |
|
393 \item there is email feedback when pushing code to github\bigskip |
|
394 |
|
395 \item we want you to learn FP: \alert{no vars}, no mutable |
|
396 datastructures, e.g.~\texttt{ListBuffer} |
|
397 \end{itemize} |
|
398 \end{frame} |
|
399 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
400 |
|
401 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
402 |
|
403 \begin{frame}[c, fragile] |
|
404 \frametitle{The Joy of Immutability} |
|
405 |
|
406 \begin{itemize} |
|
407 \item If you need to manipulate some data in a list say, then you make |
|
408 a new list with the updated values, rather than revise the original |
|
409 list. Easy!\medskip |
|
410 |
|
411 {\small |
|
412 \begin{lstlisting}[language=Scala, numbers=none, xleftmargin=-1mm] |
|
413 val old_list = List(1, 2, 3, 5) |
|
414 val new_list = 0 :: old_list |
|
415 \end{lstlisting}} |
|
416 |
|
417 \item You do not have to be defensive about who can access the data |
|
418 (concurrency, lazyness). |
|
419 \end{itemize} |
|
420 \end{frame} |
|
421 |
|
422 |
|
423 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
424 |
|
425 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
426 \begin{frame}[t] |
|
427 \frametitle{Email: Hate 'val'} |
|
428 |
|
429 \mbox{}\\[-25mm]\mbox{} |
|
430 |
|
431 \begin{center} |
|
432 \begin{bubble}[10.5cm] |
|
433 Subject: \textbf{Hate '\textbf{\texttt{val}}'}\hfill 01:00 AM\medskip\\ |
|
434 |
|
435 Hello Mr Urban,\medskip\\ |
|
436 |
|
437 I just wanted to ask, how are we suppose to work |
|
438 with the completely useless \textbf{\texttt{val}}, that can’t be changed ever? Why is |
|
439 this rule active at all? I’ve spent 4 hours not thinking on the |
|
440 coursework, but how to bypass this annoying rule. What’s the whole |
|
441 point of all these coursework, when we can’t use everything Scala |
|
442 gives us?!?\medskip\\ |
|
443 |
|
444 Regards.\\ |
|
445 \mbox{}\hspace{5mm}\textcolor{black!50}{<<deleted>>}\\ |
|
446 \end{bubble} |
|
447 \end{center} |
|
448 |
|
449 \end{frame} |
|
450 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
451 |
|
452 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
453 \begin{frame}[c] |
|
454 |
|
455 \mbox{}\\[-25mm]\mbox{} |
|
456 |
|
457 \begin{center} |
|
458 \begin{bubble}[10.5cm] |
|
459 Subject: \textbf{Re: Hate '\textbf{\texttt{val}}'}\hfill 01:02 AM\bigskip\bigskip\\ |
|
460 |
|
461 \textcolor{black!70}{ |
|
462 \textit{\large<<my usual rant about fp\ldots\\ concurrency bla bla\ldots{} better programs |
|
463 yada>>}}\bigskip\bigskip\bigskip |
|
464 |
|
465 PS: What are you trying to do where you desperately want to use \texttt{var}? |
|
466 \end{bubble} |
|
467 \end{center} |
|
468 |
|
469 \end{frame} |
|
470 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
471 |
|
472 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
473 \begin{frame}[c,fragile] |
|
474 |
|
475 \begin{textblock}{6}(0.5,0.5) |
|
476 \begin{bubble}[11.5cm] |
|
477 \small |
|
478 Subject: \textbf{Re: Re: Hate '\textbf{\texttt{val}}'}\hfill 01:04 AM\medskip\\ |
|
479 |
|
480 \textbf{Right now my is\_legal function works fine:} |
|
481 |
|
482 \footnotesize\begin{lstlisting}[language=Scala, numbers=none, xleftmargin=-1mm] |
|
483 def is_legal(dim: Int, path: Path)(x: Pos): Boolean = { |
|
484 var boolReturn = false |
|
485 if(x._1 > dim || x._2 > dim || x._1 < 0 || x._2 < 0) { |
|
486 else { var breakLoop = false |
|
487 if(path == Nil) { boolReturn = true } |
|
488 else { for(i <- 0 until path.length) { |
|
489 if(breakLoop == false) { |
|
490 if(path(i) == x) { |
|
491 boolReturn = true |
|
492 breakLoop = true |
|
493 } |
|
494 else { boolReturn = false } |
|
495 } else breakLoop |
|
496 } |
|
497 } |
|
498 boolReturn |
|
499 } |
|
500 \end{lstlisting} |
|
501 \end{bubble} |
|
502 \end{textblock} |
|
503 |
|
504 \begin{textblock}{6}(8.2,11.8) |
|
505 \begin{bubble}[5.5cm]\footnotesize\bf |
|
506 \ldots{}but I can’t make it work with boolReturn being val. What approach would |
|
507 you recommend in this case, and is using var in this case justified? |
|
508 \end{bubble} |
|
509 \end{textblock} |
|
510 |
383 \only<2>{ |
511 \only<2>{ |
384 \begin{textblock}{5}(12,2) |
512 \begin{textblock}{6}(0.3,11.8) |
385 \includegraphics[scale=0.50]{../pics/skeleton.jpg}\\ |
513 \begin{bubble}[3.1cm] |
|
514 \textbf{Me:} |
|
515 \raisebox{-12mm}{\includegraphics[scale=0.08]{../pics/throwup.jpg}} |
|
516 \end{bubble} |
386 \end{textblock}} |
517 \end{textblock}} |
387 \end{frame} |
518 |
388 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
519 \end{frame} |
|
520 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
521 |
|
522 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
523 \begin{frame}[t,fragile] |
|
524 |
|
525 \mbox{}\\[-25mm]\mbox{} |
|
526 |
|
527 \begin{textblock}{6}(0.5,2) |
|
528 \begin{bubble}[11.5cm] |
|
529 Subject: \textbf{Re: Re: Re: Hate '\textbf{\texttt{val}}'}\hfill 01:06 AM\bigskip\\ |
|
530 \small |
|
531 |
|
532 OK. So you want to make sure that the \texttt{x}-position is not outside the |
|
533 board....and furthermore you want to make sure that the \texttt{x}-position |
|
534 is not yet in the path list. How about something like\bigskip |
|
535 |
|
536 \footnotesize\begin{lstlisting}[language=Scala, numbers=none, xleftmargin=-1mm] |
|
537 def is_legal(dim: Int, path: Path)(x: Pos): Boolean = |
|
538 ...<<some board conditions>>... && !path.contains(x) |
|
539 \end{lstlisting}\bigskip |
|
540 |
|
541 \small Does not even contain a \texttt{val}. |
|
542 \end{bubble} |
|
543 \end{textblock} |
|
544 |
|
545 \begin{textblock}{6}(7,12) |
|
546 \footnotesize\textcolor{black!50}{(This is all on one line)} |
|
547 \end{textblock} |
|
548 |
|
549 \end{frame} |
|
550 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
551 |
|
552 |
|
553 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
554 \begin{frame}[t,fragile] |
|
555 |
|
556 \mbox{}\\[-15mm]\mbox{} |
|
557 |
|
558 \begin{textblock}{6}(1,3) |
|
559 \begin{bubble}[10.5cm] |
|
560 Subject: \textbf{Re: Re: Re: Re: Hate '\textbf{\texttt{val}}'}\hfill 11:02 AM\bigskip\bigskip\\ |
|
561 |
|
562 THANK YOU! You made me change my coding perspective. Because of you, |
|
563 I figured out the next one\ldots |
|
564 \end{bubble} |
|
565 \end{textblock} |
|
566 |
|
567 \only<2>{ |
|
568 \begin{textblock}{6}(0.3,11.8) |
|
569 \begin{bubble}[3.1cm] |
|
570 \textbf{Me:} |
|
571 \raisebox{-12mm}{\includegraphics[scale=0.15]{../pics/happy.jpg}} |
|
572 \end{bubble} |
|
573 \end{textblock}} |
|
574 |
|
575 \end{frame} |
|
576 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
577 |
389 |
578 |
390 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
579 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
391 \begin{frame}[c] |
580 \begin{frame}[c] |
392 \frametitle{Conclusion} |
581 \frametitle{Conclusion} |
393 |
582 |
394 \begin{itemize} |
583 \begin{itemize} |
395 \item Scala is still under heavy development\\ (the compiler is terribly slow)\medskip |
584 \item Scala is still under heavy development\\ (the compiler is terribly slow)\medskip |
396 \item {\bf\url{http://www.scala-lang.org/}}\bigskip |
585 \item {\bf\url{http://www.scala-lang.org/}}\bigskip |
397 \item it is a rather \textbf{\alert{deep}} language\ldots i.e.~gives you a lot of |
586 |
398 rope to shoot yourself\bigskip\bigskip |
587 \item it is a rather \textbf{\alert{deep}} language\ldots i.e.~gives |
399 |
588 you a lot of rope to shoot yourself\bigskip |
|
589 |
|
590 \item learning functional programming is not easy\ldots{}when you have |
|
591 spent all of your career thinking in a procedural way it is hard to |
|
592 change\bigskip\medskip |
|
593 |
400 \item hope you have fun with the coursework |
594 \item hope you have fun with the coursework |
401 \end{itemize} |
595 \end{itemize} |
402 \end{frame} |
596 \end{frame} |
403 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
597 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
404 |
598 |
405 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
599 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
406 \begin{frame}[c] |
600 \begin{frame}[c] |
407 \frametitle{\begin{tabular}{c}\\[3cm]\alert{Questions?}\end{tabular}} |
601 \frametitle{\begin{tabular}{c}\\[0cm]\alert{Questions?}\end{tabular}} |
408 |
602 |
409 \mbox{} |
603 \begin{center} |
|
604 \begin{tabular}[t]{@{}l@{}l@{}} |
|
605 \includegraphics[scale=0.1]{../pics/mand4.png} & |
|
606 \raisebox{1.2mm}{\includegraphics[scale=0.1]{../pics/mand3.png}} |
|
607 \end{tabular} |
|
608 \end{center} |
|
609 |
|
610 \begin{center} |
|
611 My Scala Office Hours: Thursdays 11 -- 13 |
|
612 \end{center} |
410 \end{frame} |
613 \end{frame} |
411 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
614 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
412 \end{document} |
615 \end{document} |
413 |
616 |
414 |
617 |