I have a matrix in terms of a 2D array and another 1-D array. I am taking one element from the matrix and checking whether it exists in the array. Following is the code.
val array_intrval = Array.ofDim[Int](10)
var joint_matrix = Array.ofDim[Int][Int](5)(2)
for(i <- 0 to 4) {
for (j <- 0 to 1) {
var a = joint_matrix(i)(j)
After this, I want to check whether a exists in array_intrval, if not add a in array_intrval and then check whether there are some elements which is less than or equal to a. If yes, also put them in array_intrval. If a does exists in array_intrval, skip a and check for next element in joint_matrix.
I am a beginner in Scala and not able perform this. Any help regarding this will be highly appreciated.
find(to locatea) andfilter(to return other elements less thana). There are some ambiguities in your description - if an element is added from a previous iteration but also matches on this iteration, do you add it again? If there are more than one element matchingado you addamultiple times? Note if you do this, thenarray_intrvalmay be too small