blob: dd639197f1ab3f7f07b2f7a54d9d9daf056030c4 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
product = foldl (*) 1
xFields = map .x
multiply x y = case y of
0 -> 0
y -> y + multiply x (y-1)
type Person = { name : String, age : Int,
address : { calle : String, pais : String } }
yo : Person
yo = { name = "Guillermo", age = 23,
address = { calle = "Arroyo Fontarrón", pais = "España" } }
tu : Person
tu = { name = "Paco", age = 15,
address = { calle = "Por allí", pais = "Congo" } }
persons = [yo, tu]
olderThan16 = filter ((>) 16 . .age)
olderThan16_safe = filter (\p -> case p.age of
Nothing -> False
Just age -> age > 16)
|