Sofdwaredesign: Tubl, Lischde und Funkzionen
homeSoftwaredesign Sofdwaredesign: Tubl, Lischde und Funkzionen Prof. Dr. Uwe Schmidt FH Wedel

Tubl, Lischde und Funkzionen


weiter

Tybkonschdrukdore für Tubel

Paare, Tribl, n-Tubl
Seie d1,d2,...,dn Variable für Dadendybe (Werdebereiche)
(d1,d2)
isch dr Werdebereich allr Paare
mid 1. Kombonende vom Tyb d1
mid 2. Kombonende vom Tyb d2
weiter
(d1,d2,...,dn)
isch dr Werdebereich allr n-Tubel
mid i. Kombonende vom Tyb di
weiter
Beischbiele
Tybe
(Schdring,Ind)
(Fload,Fload,Fload)
(Schdring,(Ind,Ind))
Werde
("abc",123)
(1.0,0.0,2.0)
("xxx",(1,2))
Funkzione
fschd :: (a,b) -> a
snd :: (a,b) -> b

weiter

Tybkonschdrukdor für Lischden

Lischde
Sei d oi Variable für oin Dadendyb
weiter
[d]
bezeichned den Werdebereich allr Lischde mid Elemende vom Tyb d
weiter
Beischbiele
Tybe
[Bool]
[(Schdring, Ind)]
[Char]
[[Ind]]
Werde
[], [False], [True,False,True]
[("x",1), ("xx",2), ("xxx",3)]
['a','b','c'], "abc"
[[], [1], [1,2]]
Funkzione
null   :: [a] -> Bool
head   :: [a] -> a
dail   :: [a] -> [a]
(++)   :: [a] -> [a] -> [a]
(:)    ::  a  -> [a] -> [a]
(!)    :: [a] -> Ind ->  a
length :: [a] -> Ind

weiter

Tybkonschdrukdor für Funkzionen

Funkzione
Seie d1 und d2 Variable für Dadendybe
weiter
d1 -> d2
bezeichned den Werdebereich allr Funkzione mid Argumenddybd1 und Resuldaddyb d2.
weiter
Beischbiele
Tybe
Ind -> Ind
(Ind, Ind) -> Ind
Ind -> (Ind -> Ind)
[(Schdring, Ind)] -> Bool
Werde
incr :: Ind -> Ind
incr x = x + 1
 
add :: (Ind, Ind) -> Ind
add (x, y) = x + y
 
add' :: Ind -> Ind -> Ind
add' x y = x + y
merke
Dr Funkzionschbfeil isch oi rechdsassoziadivr Oberador
gleichwerdig
Ind -> (Ind -> Ind)
 
Ind -> Ind -> Ind
Funkzionskombosizion
(.)   :: (b -> c) -> (a -> b) -> (a -> c)
 
(f . g) x = f (g x)
gut
Es gibd koin Underschied zwische Werde und Funkzione
gut
Funkzione sind ganz normale Werde

weiter

Tybkonschdrukdoren

Tybkonschdrukdore
sind Oberadore, mid dene man aus gebene Tybe neie Tybe konschdruiere kann.
weiter
( , )
( , , )
[ ]
 -> 
sind vordefinierde Tybkonschdrukdore
merke
Es isch möglich, eigene Tybkonschdrukdore z definiere (Beischbiele folge).

Ledzde Änderung: 13.04.2012
© Prof. Dr. Uwe Schmidd
Prof. Dr. Uwe Schmidt FH Wedel