I have some code like below. But I wish to avoid this mutable variable flag.
How can I achieve this?
def map(s: Set, f: Int => Int): Set = (x: Int) => {
var flag : Boolean = false
for(i <- -bound to bound) {
if(s(i) && f(i) == x){
flag = true
}
}
flag
}
while(!s(i) || f(i)!=x)