2
0
Fork 0
mirror of https://github.com/MartinThoma/LaTeX-examples.git synced 2025-04-26 06:48:04 +02:00

Funktionsapplikation

This commit is contained in:
Martin Thoma 2014-03-25 19:48:20 +01:00
parent 564dbc9790
commit bb674b307b
7 changed files with 44 additions and 1 deletions

View file

@ -0,0 +1,2 @@
data Tree a = Empty | Node a (Tree a) (Tree a)
deriving (Show)

View file

@ -0,0 +1,4 @@
f x = x * x
g x = x - 1
h = (f . g)
i = (g . f)

View file

@ -0,0 +1 @@
data Tree t = Node t[Tree t]

View 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)