How do you partially apply a function with multiple arguments?

James Forbes

I want to partially apply a function with an array of arguments. When I tried to use apply() on _.partial() I got a type error in lodash.

function test(){
  return ([]).join.call(arguments,' ')
}


var p = _.partial.apply(null,test,[1,2,3]) //Type Error in lodash


p(4) //should log "1 2 3 4"

Any help with this would be greatly appreciated.

elclanrs

You want:

_.partial(test, 1, 2, 3)
// equivalent to:
_.partial.apply(null, [test, 1, 2, 3])

Or dynamically:

var args = [1,2,3]

_.partial.apply(null, [test].concat(args))

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How do I partially apply an infix function like Basics.+?

From Dev

How to define function arguments partially? Python

From Dev

How to efficiently partially apply a function in R?

From Dev

How do you add multiple statements to an IF Function?

From Dev

How do you pass multiple arguments to nested route paths in Rails?

From Dev

How do you pass multiple arguments to a Luigi subtask?

From Dev

How do you pass multiple arguments into single variable in Scala

From Dev

How do you apply the same action to multiple variables efficiently in Python?

From Dev

How do you apply multiple filters and sum in ruby?

From Dev

How do you apply multiple click event listeners to images in android

From Dev

How do you apply function constraints in instance methods in Haskell?

From Dev

How do you apply a function to all values in selected cells?

From Dev

How do you apply function constraints in instance methods in Haskell?

From Dev

Apply Function Handle to Multiple Input Arguments

From Dev

Passing a function with multiple arguments to DataFrame.apply

From Dev

pasing multiple variable arguments to a function with the apply family

From Java

how do i compactly pass multiple symbol arguments into a function?

From Dev

How do we change this function to support multiple arguments?

From Dev

Partially apply function n times

From Dev

How do I apply a function with multiple parameters using `cellfun` (MATLAB)?

From Dev

How to deal with multiple arguments in function?

From Dev

Apply function to grouped data frame in Dask: How do you specify the grouped Dataframe as argument in the function?

From Dev

Autofac: How do you register a generic with multiple type arguments? Registering IGenRepo<T, TKey> with EFGenRepo<T, TKey>

From Dev

How do I partially apply (or curry) a higher order apply with generic types?

From Dev

Apply with multiple arguments, overloading

From Dev

Apply the same function multiple time with different sets of arguments

From Dev

Pandas: passing multiple column names as arguments to a function with apply

From Dev

How do you make TeamBuild 2015 multiple configuration options not apply to all steps?

From Dev

How do you pass two arguments to webpack?

Related Related

  1. 1

    How do I partially apply an infix function like Basics.+?

  2. 2

    How to define function arguments partially? Python

  3. 3

    How to efficiently partially apply a function in R?

  4. 4

    How do you add multiple statements to an IF Function?

  5. 5

    How do you pass multiple arguments to nested route paths in Rails?

  6. 6

    How do you pass multiple arguments to a Luigi subtask?

  7. 7

    How do you pass multiple arguments into single variable in Scala

  8. 8

    How do you apply the same action to multiple variables efficiently in Python?

  9. 9

    How do you apply multiple filters and sum in ruby?

  10. 10

    How do you apply multiple click event listeners to images in android

  11. 11

    How do you apply function constraints in instance methods in Haskell?

  12. 12

    How do you apply a function to all values in selected cells?

  13. 13

    How do you apply function constraints in instance methods in Haskell?

  14. 14

    Apply Function Handle to Multiple Input Arguments

  15. 15

    Passing a function with multiple arguments to DataFrame.apply

  16. 16

    pasing multiple variable arguments to a function with the apply family

  17. 17

    how do i compactly pass multiple symbol arguments into a function?

  18. 18

    How do we change this function to support multiple arguments?

  19. 19

    Partially apply function n times

  20. 20

    How do I apply a function with multiple parameters using `cellfun` (MATLAB)?

  21. 21

    How to deal with multiple arguments in function?

  22. 22

    Apply function to grouped data frame in Dask: How do you specify the grouped Dataframe as argument in the function?

  23. 23

    Autofac: How do you register a generic with multiple type arguments? Registering IGenRepo<T, TKey> with EFGenRepo<T, TKey>

  24. 24

    How do I partially apply (or curry) a higher order apply with generic types?

  25. 25

    Apply with multiple arguments, overloading

  26. 26

    Apply the same function multiple time with different sets of arguments

  27. 27

    Pandas: passing multiple column names as arguments to a function with apply

  28. 28

    How do you make TeamBuild 2015 multiple configuration options not apply to all steps?

  29. 29

    How do you pass two arguments to webpack?

HotTag

Archive