Is there a built-in function (or an easy implementation) for splitting a list into sublists based on the element value
For example, if the list is:
val myList = List("a","b","c","","e","d","a","","d","a")
and I want to split it whenever the element '' occurs (in my case I'd also remove such element, but in general it could be grouped with either the previous or following sublist), obtaining the output:
List(List("a","b","c"),List("e","d","a"),List("d","a"))
I've been digging in stack and google for an answer, but surprisingly I haven't been able to find an answer.
If it's of any help, this is something that in Mathematica I'd solve as:
SplitBy[myList, # != "" &]
(or almost equivalently using Split
)