slides/slides02.tex
changeset 319 b84ea52bfd8f
parent 318 029e2862bb4e
child 360 e45d2890749d
equal deleted inserted replaced
318:029e2862bb4e 319:b84ea52bfd8f
   439 def get_me_an_int(s: String) : Option[Int] = 
   439 def get_me_an_int(s: String) : Option[Int] = 
   440  Try(Some(Integer.parseInt(s))).getOrElse(None)
   440  Try(Some(Integer.parseInt(s))).getOrElse(None)
   441 \end{lstlisting}
   441 \end{lstlisting}
   442 \end{onlyenv}\bigskip\bigskip\bigskip
   442 \end{onlyenv}\bigskip\bigskip\bigskip
   443  
   443  
   444 in the Scala code it is clear from the type I have to deal 
   444 in the Scala code it is clear from the type I that have to deal 
   445 with the \pcode{None}-case; no JavaDoc needed
   445 with the \pcode{None}-case; no JavaDoc needed
   446   
   446   
   447 \end{frame}
   447 \end{frame}
   448 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   448 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   449  
   449  
   572 \end{lstlisting}
   572 \end{lstlisting}
   573 \end{frame}
   573 \end{frame}
   574 
   574 
   575 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%     
   575 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%     
   576 \begin{frame}[c,fragile]
   576 \begin{frame}[c,fragile]
       
   577 \frametitle{Pattern Matching}
       
   578 
       
   579 \ldots on pairs:\bigskip
       
   580 
       
   581 \begin{lstlisting}[language=Scala, numbers=none, xleftmargin=-2mm]
       
   582 def fizz_buzz(n: Int) : String = 
       
   583  (n % 3, n % 5) match {
       
   584    case (0, 0) => "fizz buzz"
       
   585    case (0, _) => "fizz"
       
   586    case (_, 0) => "buzz"
       
   587    case _ => n.toString  
       
   588  }
       
   589 \end{lstlisting}
       
   590 \end{frame}
       
   591 
       
   592 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%     
       
   593 \begin{frame}[c,fragile]
   577 \frametitle{Recursion}
   594 \frametitle{Recursion}
   578 
       
   579 
       
   580 
   595 
   581 \begin{lstlisting}[language=Scala, numbers=none, xleftmargin=-2mm]
   596 \begin{lstlisting}[language=Scala, numbers=none, xleftmargin=-2mm]
   582 def fib(n: Int) : Int = { 
   597 def fib(n: Int) : Int = { 
   583   if (n == 0 || n == 1) 1
   598   if (n == 0 || n == 1) 1
   584    else fib(n - 1) + fib(n - 2)
   599    else fib(n - 1) + fib(n - 2)
   644   \includegraphics[scale=0.3]{../pics/blow.png}
   659   \includegraphics[scale=0.3]{../pics/blow.png}
   645   \end{center}
   660   \end{center}
   646   
   661   
   647   \begin{textblock}{14}(2,11.4)
   662   \begin{textblock}{14}(2,11.4)
   648   \large\bf{}Mind-Blowing Programming Languages:\\ 
   663   \large\bf{}Mind-Blowing Programming Languages:\\ 
   649   \centering PHP
   664   \centering PHP \textcolor{gray}{(7.0)}
   650   \end{textblock}
   665   \end{textblock}
   651   \end{frame}
   666   \end{frame}
   652   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   667   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   653 
   668 
       
   669 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%     
       
   670 
       
   671 \begin{frame}[c]
       
   672 \frametitle{Jumping Towers}
       
   673 
       
   674 \begin{center}
       
   675 \begin{tikzpicture}[scale=1.2]
       
   676   \draw[line width=1mm,cap=round] (0,0) -- (5,0);
       
   677   \draw[line width=1mm,cap=round] (0,1) -- (5,1);
       
   678 
       
   679   \draw[line width=1mm,cap=round] (0,0) -- (0,1);
       
   680   \node at (0.5,0.5) {\textbf{\Large 3}};
       
   681 
       
   682   \draw[line width=1mm,cap=round] (1,0) -- (1,1);
       
   683   \node at (1.5,0.5) {\textbf{\Large 4}};
       
   684 
       
   685   \draw[line width=1mm,cap=round] (2,0) -- (2,1);
       
   686   \node at (2.5,0.5) {\textbf{\Large 2}};
       
   687 
       
   688   \draw[line width=1mm,cap=round] (3,0) -- (3,1);
       
   689   \node at (3.5,0.5) {\textbf{\Large 0}};
       
   690   
       
   691   \draw[line width=1mm,cap=round] (4,0) -- (4,1);
       
   692 
       
   693   \node at (4.5,0.5) {\textbf{\Large 1}};
       
   694   
       
   695   \draw[line width=1mm,cap=round] (5,0) -- (5,1);
       
   696 
       
   697   \draw[->,line width=0.5mm,cap=round,out=90,in=90,relative] (0.5,1) to (1.5,1);
       
   698   \draw[->,line width=0.5mm,cap=round,out=90,in=90,relative] (0.5,1) to (2.5,1);
       
   699   \draw[->,line width=0.5mm,cap=round,out=90,in=90,relative] (0.5,1) to (3.5,1);
       
   700 
       
   701   \draw[->,line width=0.5mm,cap=round,out=-90,in=-90,relative] (2.5,0) to (3.5,0);
       
   702   \draw[->,line width=0.5mm,cap=round,out=-90,in=-90,relative] (2.5,0) to (4.5,0);
       
   703 
       
   704   \draw[->,line width=0.5mm,cap=round,out=90,in=90,relative] (4.5,1) to (5.7,1);
       
   705   \node at (5.7, 0.8) {End};
       
   706 \end{tikzpicture}
       
   707 \end{center}\bigskip
       
   708 
       
   709 
       
   710 shortest: 3 $\rightarrow$ 4 $\rightarrow$ End
       
   711 
       
   712 \end{frame}
       
   713 
       
   714 
       
   715 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
       
   716 
       
   717 
       
   718 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%     
       
   719 
       
   720 \begin{frame}[c]
       
   721 \frametitle{``Children'' / moves}
       
   722 
       
   723 \begin{center}
       
   724   \begin{tikzpicture}
       
   725     [grow=right,level distance=30mm,child anchor=north,line width=0.5mm]
       
   726   \node {$[3,4,2,0,1]$}
       
   727      child {node {$[0,1]$}}
       
   728      child {node {$[2,0,1]$}
       
   729         child {node {$[1]$} child [level distance=13mm] {node {End}}}
       
   730         child {node {$[0,1]$}}
       
   731      }
       
   732      child {node {$[4,2,0,1]$\ldots}};
       
   733 \end{tikzpicture}
       
   734 \end{center}
       
   735 
       
   736 
       
   737 
       
   738 \end{frame}
       
   739 
       
   740 
       
   741 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   654 
   742 
   655 \end{document}
   743 \end{document}
   656 
   744 
   657 %%% Local Variables:  
   745 %%% Local Variables:  
   658 %%% mode: latex
   746 %%% mode: latex