소스 검색

Add pattern matching on MaybeInt

stripped-german
Julian Ospald 9 년 전
부모
커밋
40fb30148f
No known key found for this signature in database GPG 키 ID: 220CD1C5BDEED020
1개의 변경된 파일12개의 추가작업 그리고 0개의 파일을 삭제
  1. +12
    -0
      VL1.tex

+ 12
- 0
VL1.tex 파일 보기

@@ -520,6 +520,18 @@ calcSomething x
\end{lstlisting}
\end{frame}

\begin{frame}[fragile]
\frametitle{Algebraic Data Types (ctn.)}
And pattern match on it as well:
\setHaskellCodeStyle
\begin{lstlisting}
addIntToList :: MaybeInt -> [Int]
addIntToList (NoError x) = [x]
addIntToList (Error str) = []
\end{lstlisting}
So if we got an error, we just return an empty list, otherwise we return a list with the \code{Int} as its only element.
\end{frame}

\begin{frame}[fragile]
\frametitle{Algebraic Data Types (ctn.)}
Let's define something more complex. How about a tree?


불러오는 중...
취소
저장