Code shared by patterns: split, more in the futurte.
abstract class base pattern[readonly value element type]
implements validatable, pattern[element type]
extends debuggable
implement immutable list[immutable list[element type]] split(immutable list[element type] the list)
result : base list[immutable list[element type]] • new()
var index : 0
loop
match : find first(the list, index)
if match is_not null
assert match • is not empty
result • append(the list • slice(index, match • begin))
index = match • end
else
result • append(the list • skip(index))
break
return result • frozen copy()