There is a so-called “comma list”, but its use is frowned upon as bad style; and a “regular” list is easier. Here’s an example (it works because the “,
” operator is right-associative:
(a,b,c) = ','(a,','(b,c))
:
% don't do this
sum_comma_list((X,Xs), Sum) :- !, % this cut is needed
sum_comma_list(Xs, Sum0),
Sum is X + Sum0.
sum_comma_list(X, X). % X \= (_,_)
?- sum_list([1,2,3], Sum).
Sum = 6.
Here is better style (notice that it doesn’t need a cut and the clauses can be in any order and it also allows a 0-length list, whereas a “comma list” must have at least one item):
sum_list([X|Xs], Sum) :-
sum_list(Xs, Sum0),
Sum is X + Sum0.
sum_list([], 0).
?- sum_comma_list((1,2,3), Sum).
Sum = 6.