apply
¶core.lambda.
apply
(f, a)¶Returns: | The result of applying f to a . |
---|
(α → β) → α → β
Applies a function to an argument.
1 2 | var inc = function(a){ return a + 1 }
apply(inc)(3) // => 4
|
apply
can be used, together with core.lambda.flip()
in higher order
functions when mapping over a collection, if you want to apply them to some
constant argument:
1 2 3 4 5 6 7 8 | var fns = [
function(a){ return a + 2 },
function(a){ return a - 2 },
function(a){ return a * 2 },
function(a){ return a / 2 }
]
fns.map(flip(apply)(3)) => [5, 1, 6, 1.5]
|