File tree Expand file tree Collapse file tree 1 file changed +12
-10
lines changed Expand file tree Collapse file tree 1 file changed +12
-10
lines changed Original file line number Diff line number Diff line change 1
- map next [1 .. 5 ]
2
- map (\ x -> x + 1 ) [1 .. 5 ]
1
+ main = undefined
2
+
3
+ -- map next [1..5]
4
+ -- map (\x -> x + 1) [1..5]
3
5
4
6
-- CURRYING:
5
7
-- f :: X -> Y -> Z -> A
11
13
12
14
-- currying explained with lambdas:
13
15
14
- \ x y z -> x + y + z
16
+ -- \x y z -> x + y + z
15
17
16
18
-- the same as
17
19
18
- \ x -> (\ y z -> x + y + z)
20
+ -- \x -> (\y z -> x + y + z)
19
21
20
22
-- the same as
21
23
22
- \ x -> (\ y -> (\ z -> x + y + z))
24
+ -- \x -> (\y -> (\z -> x + y + z))
23
25
24
26
-- because all functions can be seen as functions with single argument, partial application is possible
25
27
26
- add x y = x+ y
27
- add x y = (add x) y
28
- add3 = add 3 -- = \y -> 3 + y
29
- add3 4 -- = (add 3) 4 = add 3 4 = 7
28
+ -- add x y = x+y
29
+ -- add x y = (add x) y
30
+ -- add3 = add 3 -- = \y -> 3 + y
31
+ -- add3 4 -- = (add 3) 4 = add 3 4 = 7
30
32
31
33
-- this is also the reason why it is possible to write things like this:
32
- map (+ 1 ) [1 .. 5 ]
34
+ -- map (+1) [1..5]
You can’t perform that action at this time.
0 commit comments