title: (Prolog) Check if a list can be split into 2 sub-lists that have equal sums
body: <p>I am using Prolog to try and check if a list can be split into 2 <strong>sublists(subarrays)</strong> that have equal sums. </p>
  
  <p>The following should succeed: [1,2,3,6], [2,1,1], [0], [1,1,2]<br>
  The following should fail: [1,4,8], [1,3,2], [2,2,1,1]</p>
  
  <p>I believe my program is creating <strong>subsequences</strong> instead of <strong>sublists</strong>. This is causing queries similar to [1,3,2] and [2,2,1,1] to succeed when they should fail. </p>
  
  <p>In the example of the query [1,3,2] it is returning true because the subsequences [1,2] and [3] have equal sums. That should not be allowed. Instead, [1,3,2] should be split into sublists [1]/[3,2] and [1,3]/[2]. Hence, it should fail.</p>
  
  <p>I am unsure how to modify the <strong><em>subL</em></strong> predicate to return sublists instead of subsequences.</p>
  
  <p>Here is what I have so far:</p>
  
  <pre><code>split([]).
  split([0]).
  split([H|T]) :- 
      subL([H|T], LEFT, RIGHT), 
      sum(LEFT, SUM1), 
      sum(RIGHT, SUM2),
      SUM1=SUM2.
  
  subL([],[],[]).
  subL([H|T], [H|T2], X) :- 
      subL(T, T2, X).
  subL([H|T], X, [H|T2]) :- 
      subL(T, X, T2).
  
  sum([H|T], SUM1) :- 
      sum(T, SUM2), 
      SUM1 is SUM2 + H.
  sum([H], SUM1) :- 
      H = SUM1. 
  </code></pre>
  
  <p>Any help with this would be greatly appreciated. Thank you</p>