0
$\begingroup$

I have a list and I want to split it into 2 sublists in all possible ways If

 S={1,2,3,4}

I should get

{{{1},{2,3,4}},{{1,2},{3,4}}......{{1,4},{2,3}}....

I'm interested in the products of the sublists so I want

 {{1,4},{2,3}} 

to appear in the result

but NOT

  {{2,3},{1,4}} or {{3,2},{1,4}} 

to appear, too.

To make things clearer, for

S={1,2,3}

the result should be

{{{1},{2,3}},{{2},{1,3}},{{3},{1,2}}}

in any order you like

NOTE: Any element in the starting list can appear more than once

S={1,2,3,3,3,4} 

is acceptable and the result should have the element

 {{1,2,3},{3,3,4}}

multiple times for ALL different 3's

$\endgroup$
  • $\begingroup$ Have you seen this? $\endgroup$ – J. M. is away Apr 9 '17 at 22:56
  • $\begingroup$ What have you tried? TBH, this is one in a series of questions from you that seem more like a specification and a "do this for me" request, vs a "Here's my work so far"/"I'm having an issue implementing this", and this site is not a mechanical turk site. Add to this the very functionality requested is an example in the documentation. So, what have you tried? $\endgroup$ – ciao Apr 9 '17 at 22:58
  • $\begingroup$ That one splits the list into 2 with half lengths.I need all possible lengths... $\endgroup$ – J42161217 Apr 9 '17 at 22:59
  • $\begingroup$ @ciao Is this a personal attack? I've tried many things that doesn't work and read many related questions.I believe that my question has not an answer yet, so it will benefit others, too.I don't understant why you're being so rude $\endgroup$ – J42161217 Apr 9 '17 at 23:03
  • $\begingroup$ @Jenny_mathy I suggest you read this, in particular "a minimal working code example of your problem or your efforts" and "some proof of minimal Mathematica knowledge". This is not a tutorial site, this is not a "do this for me" site. Nothing personal about it. $\endgroup$ – ciao Apr 9 '17 at 23:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.