I have this code:
for( i <- 0 to 8){ ((numbers(i) - i)/3).abs + ((numbers(i) - i)%3).abs }
and I would like to do, as the title says, some
Edited/Update:
Being concise, the shortest way to do it is:
def doStuff(a: Int, b: Int, op: (Int, Int) => Int) = {op(a - b, 3).abs}
doStuff(4,1,_%_)
So you can doStuff(numbers(i), i, _ / _) + doStuff(numbers(i), i, _ % _)
doStuff(numbers(i), i, _ / _) + doStuff(numbers(i), i, _ % _)