瀏覽代碼

Add common list operations

stripped-german
Julian Ospald 9 年之前
父節點
當前提交
874da65198
沒有發現已知的金鑰在資料庫的簽署中 GPG Key ID: 220CD1C5BDEED020
共有 1 個文件被更改,包括 13 次插入0 次删除
  1. +13
    -0
      VL1.tex

+ 13
- 0
VL1.tex 查看文件

@@ -386,6 +386,19 @@ infiniteList = [1..]

\begin{frame}[fragile]
\frametitle{Lists (ctn.)}
Let's check on a few very common list operations:
\setHaskellCodeStyle
\begin{lstlisting}
> [1, 2] ++ [4, 5] -- append two lists
> head [1, 2, 3] -- first element
> tail [1, 2, 3] -- everything after the head
> reverse [1, 2, 3] -- reverse a list
> take 2 [1, 2, 3] -- take the first two elements
> drop 2 [1, 2, 3] -- drop the first two elements
> sum [1, 2, 3]
> elem 7 [1, 2, 3] -- is there a 7 in the list?
\end{lstlisting}
\pause
A String in haskell is just a list of Chars!
\setHaskellCodeStyle
\begin{lstlisting}


Loading…
取消
儲存