-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAufgabe 4.1
90 lines (60 loc) · 1.21 KB
/
Aufgabe 4.1
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
//1. Aufgabe------------------
function identity_function(arg) {
return function(){
return arg
}
}
//2. Aufgabe------------------
function addf(x){
return function(y){
return x + y
}
}
// alternative:
// const addf = x => y => x+y;
//3. Aufgabe------------------
function add(x,y){
return x + y
}
function applyf(func){
return func
}
var addf = applyf(addf)
addf(1)(1)
//4. Aufgabe--------------------
function curry(func, zahl){
return func(zahl);
}
var add3 = curry(addf, 3)
add3(4)
//5. Aufgabe--------------------
function myInc(x){
return addf(x)(1)
}
//6. Aufgabe--------------------????
function methodize(f){
return function(y){
return f(this, y)
}
}
//7. Aufgabe--------------------????
function deMethodize(method){
return function(x, y){
return method.call(x, y);
}
}
Number.prototype.add = methodize(add);
deMethodize(Number.prototype.add)(5, 6)
//8. Aufgabe--------------------????
function twice(f){
return function(x){
return f(x, x);
}
}
//9. Aufgabe--------------------????
function once(){
//Methode auf null setzen nach verwendung
}
//10. Aufgabe--------------------????
function counterf(){
}