diff options
author | Iain McGinniss <iainmcgin@gmail.com> | 2013-02-19 15:18:21 +0000 |
---|---|---|
committer | Iain McGinniss <iainmcgin@gmail.com> | 2013-02-19 15:18:21 +0000 |
commit | cdaeb84fa1001f7b05e76950a11ac67e3cb2d148 (patch) | |
tree | e8b3728bc9bbce91f07f102857cbf2d1a8829251 | |
parent | 1ec5965f60ed8f3cb790fb4afcd70d1822152243 (diff) | |
download | scala-cdaeb84fa1001f7b05e76950a11ac67e3cb2d148.tar.gz scala-cdaeb84fa1001f7b05e76950a11ac67e3cb2d148.tar.bz2 scala-cdaeb84fa1001f7b05e76950a11ac67e3cb2d148.zip |
fixed inline code blocks
fixed math array for PDF output
-rw-r--r-- | 10-pattern-matching.md | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/10-pattern-matching.md b/10-pattern-matching.md index 52f22cba62..b7fcba9e45 100644 --- a/10-pattern-matching.md +++ b/10-pattern-matching.md @@ -83,7 +83,7 @@ that value. Pattern2 ::= varid `@' Pattern3 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -A pattern binder \lstinline|$x$@$p$| consists of a pattern variable $x$ and a +A pattern binder `$x$@$p$` consists of a pattern variable $x$ and a pattern $p$. The type of the variable $x$ is the static type $T$ of the pattern $p$. This pattern matches any value $v$ matched by the pattern $p$, provided the run-time type of $v$ is also an instance of $T$, @@ -170,8 +170,8 @@ repeated parameter. This is further discussed [here](#pattern-sequences). ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ A tuple pattern `($p_1 , \ldots , p_n$)` is an alias -for the constructor pattern ~\lstinline@scala.Tuple$n$($p_1 , \ldots , -p_n$)@, where $n \geq 2$. The empty tuple +for the constructor pattern `scala.Tuple$n$($p_1 , \ldots , p_n$)`, +where $n \geq 2$. The empty tuple `()`{.scala} is the unique value of type `scala.Unit`{.scala}. ### Extractor Patterns @@ -300,14 +300,14 @@ Regular expression patterns have been discontinued in Scala from version 2.0. Later version of Scala provide a much simplified version of regular expression patterns that cover most scenarios of non-text sequence processing. A _sequence pattern_ is a pattern that stands in a -position where either (1) a pattern of a type \lstinline+T+ which is +position where either (1) a pattern of a type `T` which is conforming to -\lstinline+Seq[A]+ for some \lstinline+A+ is expected, or (2) a case +`Seq[A]` for some `A` is expected, or (2) a case class constructor that has an iterated formal parameter -\lstinline+A*+. A wildcard star pattern \lstinline+_*+ in the +`A*`. A wildcard star pattern `_*` in the rightmost position stands for arbitrary long sequences. It can be -bound to variables using \lstinline+@+, as usual, in which case the variable will have the -type \lstinline+Seq[A]+. +bound to variables using `@`, as usual, in which case the variable will have the +type `Seq[A]`. ### Irrefutable Patterns @@ -397,10 +397,10 @@ type parameters $a'_1 , \ldots , a'_n$ with lower bounds $L_1 , \ldots , L_n$ and upper bounds $U_1 , \ldots , U_n$, $\mathcal{C}_0$ contains the constraints -$$\begin{array} -a_i &<:& \sigma U_i & (i = 1, \ldots , n) \\ -\sigma L_i &<:& a_i & (i = 1 , \ldots , n) -\end{array}$$ +------------- ------ -------------- ------------------------ +$a_i$ $<:$ $\sigma U_i$ $(i = 1, \ldots , n)$ +$\sigma L_i$ $<:$ $a_i$ $(i = 1 , \ldots , n)$ +------------- ------ -------------- ------------------------ where $\sigma$ is the substitution $[a'_1 := a_1 , \ldots , a'_n := a_n]$. |