Recursive formulation of multi-dimensional integration

Dear all,

I wonder whether it is possible to give a recursive formulation for
the multi-dimensional integration function. The idea is to define the
most inner integral as a function in dim-1 parameters. Proceeding in a
recursive way, one should end up with a 1-dimensional integral, which
can be solved easily.

The challenge is that I cannot access the Array parameter of function
f. Therefore I cannot define a new function on a subset of parameters
of it.

Does anyone know a solution?

Thanks and regards

Felix

def integrate( f: (Double) => Double, a : Double, b: Double, n: Int) :
Double = {
// n is some approximation parameter
// a and b are lower and upper bounds, respectively
// do 1-d integration
// res = \int_a^b f(x)dx
// solved http://en.wikipedia.org/wiki/Simpson%27s_rule

}

def integrate (f: (Array[Double]) => Double, a: Double, b: Double,
n: Int, m: Int) : Double = {
if (m == 1) {
def g(x: Double) : Double = f(Array(x))
integrate(g,a,b,n)
}
else {
//recursively call integrate(\int_a^b g(x_2,...,x_m) dx_2,...dx_m )
integrate(...,m-1)
}