handouts/ho02.tex
changeset 512 56550ad904d8
parent 511 3d4067bf4dc4
child 550 a62357075346
equal deleted inserted replaced
511:3d4067bf4dc4 512:56550ad904d8
   495 
   495 
   496 \begin{figure}[p]
   496 \begin{figure}[p]
   497   \lstinputlisting[numbers=left,linebackgroundcolor=
   497   \lstinputlisting[numbers=left,linebackgroundcolor=
   498                   {\ifodd\value{lstnumber}\color{capri!3}\fi}]
   498                   {\ifodd\value{lstnumber}\color{capri!3}\fi}]
   499                   {../progs/app5.scala}
   499                   {../progs/app5.scala}
   500 \caption{A Scala implementation of the \textit{nullable} and 
   500 \caption{A Scala implementation of \textit{nullable} and 
   501   derivative functions. These functions are easy to
   501   derivative function. These functions are easy to
   502   implement in functional languages. This is because pattern 
   502   implement in functional programming languages. This is because pattern 
   503   matching and recursion allow us to mimic the mathematical
   503   matching and recursion allow us to mimic the mathematical
   504   definitions very closely. Nearly all functional
   504   definitions very closely. Nearly all functional
   505   programming languages support pattern matching and
   505   programming languages support pattern matching and
   506   recursion out of the box.\label{scala1}}
   506   recursion out of the box.\label{scala1}}
   507 \end{figure}
   507 \end{figure}
   842 mostly by some form of induction. Remember that regular
   842 mostly by some form of induction. Remember that regular
   843 expressions are defined as 
   843 expressions are defined as 
   844 
   844 
   845 \begin{center}
   845 \begin{center}
   846 \begin{tabular}{r@{\hspace{1mm}}r@{\hspace{1mm}}l@{\hspace{13mm}}l}
   846 \begin{tabular}{r@{\hspace{1mm}}r@{\hspace{1mm}}l@{\hspace{13mm}}l}
   847   $r$ & $::=$ &   $\ZERO$         & null language\\
   847   $r$ & $::=$ &   $\ZERO$         & nothing\\
   848         & $\mid$ & $\ONE$           & empty string / \texttt{""} / []\\
   848         & $\mid$ & $\ONE$           & empty string / \texttt{""} / []\\
   849         & $\mid$ & $c$                  & single character\\
   849         & $\mid$ & $c$                  & single character\\
   850         & $\mid$ & $r_1 + r_2$          & alternative / choice\\
   850         & $\mid$ & $r_1 + r_2$          & alternative / choice\\
   851         & $\mid$ & $r_1 \cdot r_2$      & sequence\\
   851         & $\mid$ & $r_1 \cdot r_2$      & sequence\\
   852         & $\mid$ & $r^*$                & star (zero or more)\\
   852         & $\mid$ & $r^*$                & star (zero or more)\\