2015-04-23 00:06:32 +00:00
|
|
|
\ifger{Ein paar häufig verwendete List-Operationen}{Let's check on a few very common list operations:}
|
2015-04-20 18:15:46 +00:00
|
|
|
\begin{haskellcode*}{bgcolor=mygrey,frame=single,numbers=none,label=GHCi}
|
2015-04-20 18:14:07 +00:00
|
|
|
> [1, 2] ++ [4, 5] -- append two lists
|
|
|
|
> head [1, 2, 3] -- first element
|
|
|
|
> tail [1, 2, 3] -- everything after the head
|
2015-04-19 22:32:01 +00:00
|
|
|
> reverse [1, 2, 3] -- reverse a list
|
2015-04-20 18:14:07 +00:00
|
|
|
> take 2 [1, 2, 3] -- take the first two elements
|
|
|
|
> drop 2 [1, 2, 3] -- drop the first two elements
|
2015-04-19 22:32:01 +00:00
|
|
|
> sum [1, 2, 3]
|
2015-04-20 18:14:07 +00:00
|
|
|
> elem 7 [1, 2, 3] -- is there a 7 in the list?
|
2015-04-20 18:15:46 +00:00
|
|
|
\end{haskellcode*}
|
2015-04-19 22:32:01 +00:00
|
|
|
\pause
|
2015-04-23 00:06:32 +00:00
|
|
|
\ifger{Ein String in Haskell ist einfach nur eine Liste von Chars!}{A String in haskell is just a list of Chars!}
|
2015-04-20 18:15:46 +00:00
|
|
|
\begin{haskellcode*}{bgcolor=mygrey,frame=single,numbers=none,label=GHCi}
|
2015-04-19 22:32:01 +00:00
|
|
|
> ['a', 'b', 'c']
|
|
|
|
> 'a' : []
|
|
|
|
> head "abc"
|
|
|
|
> 'a' ++ 'c'
|
2015-04-20 18:15:46 +00:00
|
|
|
\end{haskellcode*}
|