i new scala , i'm not sure best way convert for/if loop have written in c++ scala. i'm working on translating entire document if give me first step helpful!
suppose array1, array2, array3 , array4 initialised , of size n-1
the code is
 n=10  k=4  for(i=0,i<n,i++) {   if (array1(i) > k){     array2(i)=0   }   else if (array1(i)>-k) {      if (array3(i)>0) {       array2(i)=1       array4(i)=2     }     else {       array2(i)=2       array4(i)=0     }   else {     array2(i)=3     array4(i)=4   } } 
in case like
for( n <- 0 until 10){ ... } would simplest loop. until exclusive end. if want loop inclusive end, use to instead of until. might want consider using pattern matching instead of nested if/elses. here links cover basics of scala in interactive way: http://scalatutorials.com/
Comments
Post a Comment