look deeper into conditions
look deeper into conditions

This finally closes Ulrich Neumerkel's i3a#309:

   list_sum([E|Es],S1) :- S1 #= E+S2, list_sum(Es,S2).

Previously:

   %?- listing(list_sum/2).
   %@ list_sum([], 0).
   %@ list_sum([B|E], A) :-
   %@ 	(   integer(A)
   %@ 	->  (   integer(B),
   %@ 		integer(C)
   %@ 	    ->  A=:=B+C
   %@ 	    ;   D is A,
   %@ 		clpfd:clpfd_equal(D, B+C)
   %@ 	    )
   %@ 	;   integer(B),
   %@ 	    integer(C)
   %@ 	->  (   var(A)
   %@ 	    ->  A is B+C
   %@ 	    ;   D is B+C,
   %@ 		clpfd:clpfd_equal(A, D)
   %@ 	    )
   %@ 	;   clpfd:clpfd_equal(A, B+C)
   %@ 	),
   %@ 	list_sum(E, C).
   %@
   %@ true.

Now:

   %?- listing(list_sum/2).
   %@ list_sum([], 0).
   %@ list_sum([C|E], A) :-
   %@ 	(   integer(A)
   %@ 	->  B is A,
   %@ 	    clpfd:clpfd_equal(B, C+D)
   %@ 	;   clpfd:clpfd_equal(A, C+D)
   %@ 	),
   %@ 	list_sum(E, D).
   %@
   %@ true.

jn7163/swipl-devel,edechter/swipl-devel,edechter/swipl-devel,jn7163/swipl-devel,mndrix/swipl-devel,mndrix/swipl-devel,mndrix/swipl-devel,edechter/swipl-devel,jn7163/swipl-devel,koryonik/swipl-devel,koryonik/swipl-devel,koryonik/swipl-devel,koryonik/swipl-devel,jn7163/swipl-devel,edechter/swipl-devel,mndrix/swipl-devel,jn7163/swipl-devel,edechter/swipl-devel,koryonik/swipl-devel,mndrix/swipl-devel