We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 4d3d944 + 3ce7d85 commit 6f8b215Copy full SHA for 6f8b215
JavaScript/6-functor-ap-fp.js
@@ -12,3 +12,24 @@ function maybe(x) {
12
maybe(5)(x => x * 2)(x => ++x)(console.log);
13
maybe(5)(x => x * 2).ap(maybe(x => ++x))(console.log);
14
maybe(5).chain(x => maybe(x * 2))(x => ++x)(console.log);
15
+
16
+const config = {
17
+ coords: {
18
+ x: 0,
19
+ y: 5,
20
+ },
21
+ velocity: {
22
+ x: 1,
23
+ y: 1,
24
25
+};
26
27
+const addVelocity = velocity => coords => {
28
+ coords.x += velocity.x;
29
+ coords.y += velocity.y;
30
+ return coords;
31
32
33
+const coords = maybe(config.coords);
34
+const velocity = maybe(config.velocity);
35
+coords.ap(velocity(addVelocity))(console.log);
0 commit comments