Question: Complete the predicate below that is to add up all the numbers in a list but uses an alternating sign. using prolog. please help me

Complete the predicate below that is to add up all the numbers in a list but uses an alternating sign. using prolog.

Complete the predicate below that is to add up all the numbers

please help me with this number.

?- addAlternate([5,6,1],s). ?- addAlternate([3,1,5,2,7,3],s) addAlternate(L,S)- addAlternate( addAlternate([HT],A,p,S):- !, AA is A H, addAlternate(T,AA,m, S) addAlternate([HT],A,m,S) !, AA is A - H, addAlternate (T,AA,p,S)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!