Is there a builtin method on Swift Array
s which splits it into two pieces, preserving the order of all elements?
Something akin to Array.prefix and Array.suffix
, combined into one?
I'm aware of partition
and split
, but they don't preserve order and size, respectively.
Example:
[1,2,3,5,6,2,3,5].cut(where: { $0 < 5 })
>>> ([1,2,3], [5,6,2,3,5])