Grundlagen der Funktionalen Programmierung: Typen und Klassen |
|
|
|
|
|
|
|
|
1module Types
2where
3
4-- ----------------------------------------
5
6l1 = [False, True]
7
8l2 = ['a', 'b', 'c']
9
10l3 = ["abc", "xyz", "123"]
11
12l4 = []
13
14-- ----------------------------------------
15
16p1 = (False, True)
17
18p2 = (False, 'a', True)
19
20p3 = ("ja", True, 'a')
21
22-- ----------------------------------------
23
24c1 = ('a', (False, 'b'))
25
26c2 = (['a'],['b'])
27
28c3 = [("abc", False)]
29
30-- ----------------------------------------
31
32add :: (Int, Int) -> Int
33add = \ (x,y) -> x + y
34
35add' :: Int -> (Int -> Int)
36add' = \ x -> (\ y -> x + y)
37
38add'' :: Int -> Int -> Int
39add'' x y = x + y
40
41zeroto :: Int -> [Int]
42zeroto = \ n -> [0 .. n]
43
44mul3 :: Int -> (Int -> (Int -> Int))
45mul3 = \ x -> (\ y -> (\ z -> x * y * z))
46
47mul3' :: Int -> Int -> Int -> Int
48mul3' x y z = x * y * z
49
50mul2 = mul3 2
51
52succ' = add' 1
53
54pred' = add' (-1)
|
Types.hs |
Letzte Änderung: 24.11.2020 | © Prof. Dr. Uwe Schmidt |