I am trying to do something like this in Haskell using the Data.Vector.* packages, and I really have no idea where to start. I'm a newb to Haskell, with a tenuous grasp of certain core concepts (but I'm getting there).
What I'm trying to do can be expressed approximately by the following C code:
float *arrA = /* initialized to array of length n */;
float *arrB = /* initialized to array of length n */;
for (i = 1; i < n; i++) {
for (j = 0; j < n - i; j++) {
arrB[j] = someFn(i, j, arrA[j], arrB[j+1])
}
float *p = arrA;
arrA = arrB;
arrB = p;
}
return arrA[0];
Points to note:
- Reuse of arrays for performance reasons, but I need two of them to avoid trampling required values for the next iteration
- Arrays are swapped
- Upper bound of inner loop changes with each iteration of outer loop
Any help that you might offer would be greatly appreciated.