flattenLambda()
Motivation:
.flattenLast() presumes the last argument is the collection to flatten. But it could be the first argument, or a property of the any argument, or a list calculated from 2 arguments.
Proposal:
provide a lambda method to the flatten() so the user can figure it out themselves
Strawmans:
Uni:
forEach(Shift) // Uni<Shift>
.flatten(shift -> shift.getRequiredSkills)) // Bi<Shift, Skill>
Bi:
forEach(Shift).join(Day, overlapping(...) // Bi<Shift, Day>
.flatten((shift, day) -> extractOverlappingHours(shift, day)) // Tri<Shift, Day, Hour>
This would make .flattenFirst() no longer a feature gap (at most a syntactic sugar gap). This would make .expand().flattenLast() less code and faster (no intermediate tuples)
This would turn the tables: .flattenLast() is syntactic sugar for .flattenLambda.
Naming proposals:
A) .flattenLambda() B) .flatten() C) .flattenAndExpand() D).expandAndFlatten()
I think A) .flattenLambda() is a terrible name. I maybe prefer B so far.