handouts/notation.tex
changeset 246 baf41b05210f
parent 242 35104ee14f87
child 266 ae039d6ae3f2
equal deleted inserted replaced
245:a5fade10c207 246:baf41b05210f
   104 
   104 
   105 Occasionally we will use the notation $a^n$ for strings, which 
   105 Occasionally we will use the notation $a^n$ for strings, which 
   106 stands for the string of $n$ repeated $a$s. So $a^{n}b^{n}$ is
   106 stands for the string of $n$ repeated $a$s. So $a^{n}b^{n}$ is
   107 a string that has as many $a$s as $b$s.
   107 a string that has as many $a$s as $b$s.
   108 
   108 
   109 While for us strings are just lists of characters, programming
   109 Note however that while for us strings are just lists of
   110 languages often differentiate between the two concepts. In
   110 characters, programming languages often differentiate between
   111 Scala, for example, there is the type of \code{String} and the
   111 the two concepts. In Scala, for example, there is the type of
   112 type of lists of characters,  \code{List[Char]}. They are not
   112 \code{String} and the type of lists of characters,
   113 the same and we need to explicitly coerce elements between the
   113 \code{List[Char]}. They are not the same and we need to
   114 two types, for example
   114 explicitly coerce elements between the two types, for example
   115 
   115 
   116 \begin{lstlisting}[numbers=none]
   116 \begin{lstlisting}[numbers=none]
   117 scala> "abc".toList
   117 scala> "abc".toList
   118 res01: List[Char] = List(a, b, c)
   118 res01: List[Char] = List(a, b, c)
   119 \end{lstlisting}
   119 \end{lstlisting}
   282 this alphabet $\Sigma^*$. In doing so we also include the 
   282 this alphabet $\Sigma^*$. In doing so we also include the 
   283 empty string as a possible string over $\Sigma$. So if
   283 empty string as a possible string over $\Sigma$. So if
   284 $\Sigma = \{a, b\}$, then $\Sigma^*$ is
   284 $\Sigma = \{a, b\}$, then $\Sigma^*$ is
   285 
   285 
   286 \[
   286 \[
   287 \{[], a, b, ab, ba, aaa, aab, aba, abb, baa, bab, \ldots\}
   287 \{[], a, b, aa, ab, ba, bb, aaa, aab, aba, abb, baa, bab, \ldots\}
   288 \]
   288 \]
   289 
   289 
   290 \noindent or in other words all strings containing $a$s and 
   290 \noindent or in other words all strings containing $a$s and
   291 $b$s only.
   291 $b$s only, plus the empty string.
   292 
   292 
   293 \end{document}
   293 \end{document}
   294 
   294 
   295 %%% Local Variables: 
   295 %%% Local Variables: 
   296 %%% mode: latex
   296 %%% mode: latex