I am trying to swap each pair of values โโin my array using for and yield, and so far I am very unsuccessful. I tried to do the following:
val a = Array(1,2,3,4,5) //What I want is Array(2,1,4,3,5) for(i<-0 until (a.length-1,2),r<- Array(i+1,i)) yield r
The above fragment returns the vector 2,1,4,3 (and 5 is omitted)
Can someone point out what I'm doing wrong here, and how to get the correct U-turn using for and gives?
thanks
sc_ray
source share