I have a list of items in Scala, and I'm looking for a way to split the list when a duplicate is detected.
For example: List(x,y,z,e,r,y,g,a)will be converted to List(List(x,y,z,e,r),List(y,g,a))
or List(x,y,z,x,y,z)before List(x,y,z), List(x,y,z)
and List(x,y,z,y,g,x)beforeList(x,y,z), List(y,g,x)
Is there a more efficient way than repeating and recording on each item separately?