diff options
author | Ignacio Burgueño <ignaciob@inconcertcc.com> | 2015-08-29 19:47:44 +0300 |
---|---|---|
committer | Ignacio Burgueño <ignaciob@inconcertcc.com> | 2015-08-29 19:47:44 +0300 |
commit | 29a71f052675f6a40cebaf5c4bea50e21b6fdc31 (patch) | |
tree | dd48bc7582c6915db736d157bbc4905bf741be91 /doc | |
parent | daf91d0333e9b6d345ff37c698925dcb12caeec9 (diff) |
Adds _.bind2
Similar to `_.bind`, but binds a value to the second argument of the function.
I found myself in need of something like this mostly when using _.compose and functions like _.last.
Now I'm able to write things like:
```lua
local last2 = _.bind2(_.last, 2)
_.compose(last2, _.compact)
````
Diffstat (limited to 'doc')
-rw-r--r-- | doc/tutorial.md | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/doc/tutorial.md b/doc/tutorial.md index 2645bfa..bbc5b02 100644 --- a/doc/tutorial.md +++ b/doc/tutorial.md @@ -1079,6 +1079,15 @@ local sqrt2 = _.bind(math.sqrt,2) sqrt2() -- => 1.4142135623731 ```` +### bind2 (f, v) + +Binds a value to be the second argument to a function. + +```lua +local last2 = _.bind(_.last,2) +last2({1,2,3,4,5,6}) -- => {5,6} +```` + ### bindn (f, ...) Binds a variable number of values to be the first arguments to a function. |