Prolog - Sum up “positioned” elem in list?

This looks like homework, so I'll just give you a nudge in the right direction. The problem is really two separate problems: filter and sum. Solve these separately, and implement odd by composing the solutions.

The sum of 'odd-positioned' elements can be found by the following; where lists are indexed from 0: odd_sum_nth0(_,X|Y, Sum) :- odd_sum_aux(Y, X, Sum). Else, were lists are indexed from 1: odd_sum_nth1(X|Y, Sum) :- odd_sum_aux(Y, X, Sum). Given: odd_sum_aux(_, W|X, Y, Sum) :-!

, Z is W + Y, odd_sum_aux(X, Z, Sum). Odd_sum_aux(_, Sum, Sum). Caveat emptor.

;-).

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions