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 regels
1.3 KiB

  1. \ifger{Haskell erlaubt auch}{Haskell also supports} \textbf{list comprehension} \ifger{, was eigentlich nur Syntaxsugar ist und der mathematischen Schreibweise sehr ähnelt.}{which is basically syntactic sugar for what we already know from maths.}\\
  2. \ifger{Wir wollen ein Set definieren, das die ersten 10 geraden Zahlen beinhaltet:}{Let's define a set that contains the first ten even natural numbers:}\\
  3. \pause
  4. $S = \{2 \times x\ |\ x \in \mathbb{N},\ x \leq 10\}$
  5. \vspace{\baselineskip}
  6. \pause
  7. \\
  8. \ifger{Wie könnte das in Haskell aussehen?}{How does this look in haskell?}
  9. \pause
  10. \begin{haskellcode*}{bgcolor=mygrey,frame=single,numbers=none,label=GHCi}
  11. > [ 2 * x | x <- [1..10]]
  12. \end{haskellcode*}
  13. \pause
  14. \ifger{Jetzt wollen wir alle Zahlen zwischen 50 und 100 die als Rest 0 haben, wenn wir sie modulo 12 nehmen:}{Now let's say we want all numbers between 50 and 100 that have the remainder 0 when divided by 12:}
  15. \pause
  16. \begin{haskellcode*}{bgcolor=mygrey,frame=single,numbers=none,label=GHCi}
  17. > [x | x <- [50..100], mod x 12 == 0]
  18. \end{haskellcode*}
  19. \hinline{x <- [50..100]} \ifger{ist das Binding, während}{is the binding, while} \hinline{mod x 12 == 0} \ifger{das Prädikat ist}{is the predicate}, \ifger{getrennt durch ein Komma}{separated by a comma}. \ifger{Wir können mehrere Prädikate haben}{We can have multiple predicates.}