I am fairly new to scala and to functional programming in general so this might be a silly question to some. Anyway, I tried to search online, read some tutorials and the book ScalaByExample but I haven't found/reached the part where I can answer my inqury.
Here's my problem:
I have several functions that has these forms:
def func1(A: Array[Array[DataType]], B: Array[Array[DataType]],
fn: (DataType, DataType) => PotentiallyDifferentDataType): Array[Array[DataType]] = {
// Do something in each element using fn
}
def func2(A: Array[DataType], B: Array[DataType],
fn: (DataType, DataType) => PotentiallyDifferentDataType) = {
// Do something for each element using fn
}
What I want to do is create a function that accepts 1D or 2D arrays and perform element-wise operations on those arrays where the elements of those arrays might be boolean
, int
, float
or double
.