Browse Source

Add common list operations

Julian Ospald 4 years ago
parent
commit
874da65198
No account linked to committer's email address
1 changed files with 13 additions and 0 deletions
  1. 13
    0
      VL1.tex

+ 13
- 0
VL1.tex View File

@@ -386,6 +386,19 @@ infiniteList = [1..]
386 386
 
387 387
 \begin{frame}[fragile]
388 388
 \frametitle{Lists (ctn.)}
389
+Let's check on a few very common list operations:
390
+\setHaskellCodeStyle
391
+\begin{lstlisting}
392
+> [1, 2] ++ [4, 5] -- append two lists
393
+> head [1, 2, 3] -- first element
394
+> tail [1, 2, 3] -- everything after the head
395
+> reverse [1, 2, 3] -- reverse a list
396
+> take 2 [1, 2, 3] -- take the first two elements
397
+> drop 2 [1, 2, 3] -- drop the first two elements
398
+> sum [1, 2, 3]
399
+> elem 7 [1, 2, 3] -- is there a 7 in the list?
400
+\end{lstlisting}
401
+\pause
389 402
 A String in haskell is just a list of Chars!
390 403
 \setHaskellCodeStyle
391 404
 \begin{lstlisting}