From 874da651981268bd118b7df86af09df748b80071 Mon Sep 17 00:00:00 2001 From: Julian Ospald Date: Wed, 15 Apr 2015 18:14:34 +0200 Subject: [PATCH] Add common list operations --- VL1.tex | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/VL1.tex b/VL1.tex index 9dcd07b..424b62a 100644 --- a/VL1.tex +++ b/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}