Open EverybodyKurts opened 6 years ago
This seems very similar to List.Extra.groupsOfVarying
. Do you have some specific use-case in mind for which that function is not sufficient?
I believe there are some slight differences between groupsOfVarying
and my proposed splitsAt
function. groupsOfVarying
specifies the length of each group while splitsAt
specifies the index of where the split should end. groupsOfVarying
can return a list of lists that doesn't necessarily include all elements in the original list while splitsAt
does include all elements in the original list.
I haven't tested splitsAt
with list of indices like [3,2,1]
or [1,1,1]
.
Im not seeing the value in this function to be honest. Assuming good code practices were used, I dont know how you could end up in a circumstance where you could know which indices you want to split at without also having access to the elements you are trying to split.
It would be defined something like this:
I'd be more than happy to create a merge request using the module formatting for documentation and the like. Let me know.