Stephen,
I took the liberty of rewriting the implementation of Iter.mapMany - it
didn't cope with the case where one of the sub-iterators returned was
zerolength because it created the iterator and immediately called .next().
The situation occurred in the SPARQL WG test suite for Update, where a
binding didn't generate any legal quads.(TemplateLib.calcQuads).
Where did the name "mapMany" come from? It's called "flatMap in scala.
The implement of flatmap is shorter :-) ... and recursive (the while
loop in mapMany is removing that tail recursion).
Andy
scala.collection.Iterator[A]
def flatMap[B](f: A => GenTraversableOnce[B]): Iterator[B]
= new Iterator[B] {
private var cur: Iterator[B] = empty
def hasNext: Boolean =
cur.hasNext || self.hasNext &&
{ cur = f(self.next).toIterator; hasNext }
def next(): B = (if (hasNext) cur else empty).next()
}