haskell-lectures/VL1/content/VL1_lists2.tex
Julian Ospald f36590c9f4
Restructure files, make the latex code more modular
Also added a few more section to make beamer and article more
compatible.
2015-04-20 17:38:58 +02:00

19 lines
553 B
TeX

Let's check on a few very common list operations:
\begin{haskellcode}
> [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{haskellcode}
\pause
A String in haskell is just a list of Chars!
\begin{haskellcode}
> ['a', 'b', 'c']
> 'a' : []
> head "abc"
> 'a' ++ 'c'
\end{haskellcode}