Passing tuples to function parameters

Will I Am

Suppose I have this code:

def a(x:Int,y:Int):Int = x+y

def b:(Int,Int) = (1,2)

and I would like to accomplish:

  a(b)

What is the proper way of doing this? Also are there more efficient ways of calling a predefined multi-parameter function - in my case 8 - with the results of another function?

j-keck

how about:

scala> (a _).tupled(b)
res0: Int = 3
  • a is a method. a _ gives you a partially applied function.
  • Function2.tupled creates a tupled version from your function.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Java

Passing parameters to a Bash function

From Dev

Passing extra parameters into the stat function

From Dev

zip generators passing parameters from a list of tuples

From Dev

Function in onclick of tag <a> passing parameters

From Dev

Passing function parameters and no return statement

From Dev

Passing "*&" parameters to a function

From Dev

Passing on the parameters of a function into another one?

From Dev

Passing parameters to a function in yii

From Dev

Passing selectors as function parameters in jQuery

From Dev

Passing parameters to a resolve function

From Dev

Passing a list of parameters into a Python function

From Dev

Passing parameters to function closure

From Dev

Calling or Passing Optional Parameters to Function

From Dev

passing two parameters to fminunc function

From Dev

Passing parameters to a function in Ajax

From Dev

Passing SOME of the parameters to a function in python

From Dev

F# tuples into function parameters

From Dev

passing additional parameters to two function

From Dev

Passing SQL function parameters

From Dev

passing parameters in python function

From Dev

Passing dynamic parameters into a function

From Dev

Passing parameters to a resolve function

From Dev

Passing parameters to a Matlab function

From Dev

Passing parameters with space to function

From Dev

Passing parameters to a function in Ajax

From Dev

F# tuples into function parameters

From Dev

Passing parameters to a BASH function

From Dev

Passing function references as parameters

From Dev

passing parameters to function