def flatten3(l: List[_]): List[_] = {
l.flatMap(a => {
if (a.isInstanceOf[List[_]]) flatten3(a.asInstanceOf[List[_]])
else List(a)
})
}
Friday, 1 May 2009
Scala - Flatten lists & use asInstanceOf
Subscribe to:
Post Comments (Atom)
def flatten3(l: List[_]): List[_] = {
l.flatMap(a => {
if (a.isInstanceOf[List[_]]) flatten3(a.asInstanceOf[List[_]])
else List(a)
})
}
No comments:
Post a Comment