Given an array of strings
["the" "cat" "sat" "on" "the" "mat"]
I'm looking to get all combinations of items in sequence, from any starting position, e.g.
["the"]
["the" "cat"]
["the" "cat" "sat"]
...
["cat" "sat" "on" "the" "mat"]
["sat" "on" "the" "mat"]
["on" "the" "mat"]
...
["sat" "on"]
["sat" "on" "the"]
Combinations out of the original sequence or with missing elements are disallowed, e.g.
["sat" "mat"] # missing "on"
["the" "on"] # reverse order
I'd also like to know if this operation has a particular name or if there's a neater way of describing it.
Thanks.