The sum_list(X,Y) goal succeeds if sum of elements in the list X matches Y.
Examples
?- sum_list([], X).
X = 0
yes
?- sum_list([42], X).
X = 42
yes
?- sum_list([42.0], X).
X = 42.0
yes
?- sum_list([3, 8, 180], X).
X = 191
yes
?- sum_list([10, 2, 4.5], X).
X = 16.5
yes
?- sum_list([3, 6*7, 180], X).
X = 225
yes
?- sum_list([3, 6*7.0, 180], X).
X = 225.0
yes
?- sum_list([2, 3, 4], 9).
yes
?- sum_list([2, 3, 4], 8).
no
?- sum_list([2, 3, 4], 10).
no
?- sum_list(X, 1).
Expected LIST but got: VARIABLE with value: X
?- sum_list(a, X).
Expected LIST but got: ATOM with value: a
?- sum_list([1, a, 3], X).
Cannot find arithmetic operator: a/0