Bit unsure on how to phrase this properly, so bear with me!
Given a list [1,2,3,4] I want a list of tuples of lists, like so: [([1],[2,3,4]),([1,2],[3,4]),([1,2,3],[4])].
A part B of the question would be to get all possible orderings inside sublists too. So in the case of the first tuple, I’d want the 2 3 4 in the order 243, 324, 432, 423…
Yes, I like non-determinism.
For part b, I’m not sure whether you want
[([1],[2,3,4]), ([1],[3,4,2]), ...]or[([1],[[2,3,4],[3,4,2],...]), ...]. If the latter, thenEdit: Oh, but you want the former. In that case
Final edit: As I’ve already used a couple of functions from Control.Arrow, I’ll note thatzip (inits xs) (tails xs)can also be written as(inits &&& tails) xs, but I’m not sure it’s clearer that way.