mirror of
https://github.com/MartinThoma/LaTeX-examples.git
synced 2025-04-26 06:48:04 +02:00
Funktionsapplikation
This commit is contained in:
parent
564dbc9790
commit
bb674b307b
7 changed files with 44 additions and 1 deletions
|
@ -0,0 +1,2 @@
|
|||
data Tree a = Empty | Node a (Tree a) (Tree a)
|
||||
deriving (Show)
|
|
@ -0,0 +1,4 @@
|
|||
f x = x * x
|
||||
g x = x - 1
|
||||
h = (f . g)
|
||||
i = (g . f)
|
|
@ -0,0 +1 @@
|
|||
data Tree t = Node t[Tree t]
|
5
documents/Programmierparadigmen/scripts/haskell/mapt.hs
Normal file
5
documents/Programmierparadigmen/scripts/haskell/mapt.hs
Normal file
|
@ -0,0 +1,5 @@
|
|||
mapT :: (t -> s) -> Tree t -> Tree s
|
||||
mapT f (Node x ts) = Node (f x) (map (mapT f) ts)
|
||||
|
||||
reduceT :: (t -> t -> t) -> Tree t -> t
|
||||
reduceT f (Node x ts) = foldl f x (map (reduceT f) ts)
|
Loading…
Add table
Add a link
Reference in a new issue