How does this code throw away the first item in the list?
By calling on
recursivelly on the list's tail, you're ignoring the first element. And since you won't use it, you should call it _
instead of DisregardHead
(some compilers will warn you of "singleton variable").
once I've found it, how do I use it to calculate as described above?
Well, on
is supposed to return multiple results - one for each match - while your goal is to have a single result that takes the whole list into account. So you shouldn't disregard the first element, but incorporate it in the results. Example:
my_pred([],0).
my_pred([Item|Tail],Result) :-
my_pred(Tail,IntermResult),
combine(Item,IntermResult,Result). % Ex.: Result is Item + IntermResult
I haven't given a complete code since it appears you're still learning, but can do if that's what you want. This is also a very simple example, and not optimized (i.e. no tail recursion).
Additional hint: if you express your polinomial this way, it should become clear how a recursive calculation could be done:
1 + x * (3 + x * (3 + x * (2 + x * 0)))