each item from it.
functional :: FlatMapIter :: defaultinit
functional :: FlatMapIter :: f
functional :: FlatMapIter :: f=
functional :: FlatMapIter :: inner
functional :: FlatMapIter :: inner=
functional :: FlatMapIter :: try_compute_inner
Tries to resolve the inner iterator.functional $ FlatMapIter :: SELF
Type of this instance, automatically specialized in every classfunctional $ FlatMapIter :: init
functional :: FlatMapIter :: defaultinit
functional :: FlatMapIter :: f
functional :: FlatMapIter :: f=
functional :: FlatMapIter :: inner
functional :: FlatMapIter :: inner=
functional :: FlatMapIter :: try_compute_inner
Tries to resolve the inner iterator.
# An iterator that maps each item to an iterator and yield
# each item from it.
class FlatMapIter[A,B]
super FunIter[A,B]
var f: Fun1[A, Iterator[B]]
protected var inner: nullable Iterator[B] = null
redef init
do
try_compute_inner
end
redef fun item
do
return inner.as(not null).item
end
redef fun is_ok
do
return inner != null
end
redef fun next
do
inner.next
if not inner.is_ok then
super
try_compute_inner
end
end
# Tries to resolve the inner iterator.
# Assigns null to `inner` if it fails.
protected fun try_compute_inner
do
inner = null
if not my_iter.is_ok then return
var res = f.call(my_iter.item)
if res.is_ok then inner = res
end
end
lib/functional/iter_extras.nit:310,1--350,3