You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: 1-js/06-advanced-functions/11-currying-partials/article.md
+19-18
Original file line number
Diff line number
Diff line change
@@ -119,13 +119,11 @@ Also there's a ready [_.partial](https://lodash.com/docs#partial) implementation
119
119
120
120
Sometimes people mix up partial function application mentioned above with another thing named "currying". That's another interesting technique of working with functions that we just have to mention here.
121
121
122
-
[Currying](https://en.wikipedia.org/wiki/Currying) is translating a function from callable as `f(a, b, c)` into callable as `f(a)(b)(c)`.
122
+
[Currying](https://en.wikipedia.org/wiki/Currying) is a transformation of functions that translates a function from callable as `f(a, b, c)` into callable as `f(a)(b)(c)`. In JavaScript, we usually make a wrapper to keep the original function.
123
123
124
-
Literally, currying is a transformation of functions: from one way of calling into another. In JavaScript, we usually make a wrapper to keep the original function.
124
+
Currying doesn't call a function. It just transforms it.
125
125
126
-
Currying doesn't call a function. It just transforms it. We'll see use cases soon.
127
-
128
-
Let's make `curry` function that performs currying for two-argument functions. In other words, `curry(f)` for two-argument `f(a, b)` translates it into `f(a)(b)`
126
+
Let's create a helper `curry(f)` function that performs currying for a two-argument `f`. In other words, `curry(f)` for two-argument `f(a, b)` translates it into `f(a)(b)`
129
127
130
128
```js run
131
129
*!*
@@ -168,9 +166,11 @@ function curry(f) {
168
166
169
167
## Currying? What for?
170
168
171
-
To understand the benefits we definitely need a worthy real-life example. Advanced currying allows the function to be both callable normally and get partials.
169
+
To understand the benefits we definitely need a worthy real-life example.
170
+
171
+
Advanced currying allows the function to be both callable normally and partially.
172
172
173
-
For instance, we have the logging function `log(date, importance, message)` that formats and outputs the information. In real projects such functions also have many other useful features like: sending it over the network or filtering:
173
+
For instance, we have the logging function `log(date, importance, message)` that formats and outputs the information. In real projects such functions also have many other useful features like sending logs over the network:
0 commit comments