so that it returns the flat mapped elements as wel...
# getting-started
e
so that it returns the flat mapped elements as well as the remaining > n elements
o
I don’t think there is such a function, but I’m also not sure what you want as a return type?
e
the return type would be a collection that contains the elements that were flat mapped as well as the remaining unmapped elements. so a collection of elements, not a collection of collections
i should probably also mention the function i'm flatmapping is going to return the same type. sort of like if i had a list of tree nodes and the flatmap operation was to get the child nodes
o
It looks more like tree traversal sequence, which can be implemented much more efficient than creating a list.
😁 1
i
mapIndexed { index, node -> if (index < n) node else listOf(node) }
and then
.flatten()
😁 1
e
looks like what i need, thanks a lot 🙂