You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

19 lines
796 B

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