i have a problem
i have a list for example [9,8,7,6,5,4,3,2,1] and i want to find the difference between each two elements for example 9-8, 8-7, 7-6, ... i have done something but it's not what i want it does this 9-8 , 7-6 , 5-4 ,.... and it stops at 2 the previous element from the end of list. that's what i 've got so far
diff(X,Y, [X,Y|_]). diff(X,Y, [_,_|Tail]) :- diff(Tail,Y,X),Z is X - Y,print(Z).
and if someone show me how to put the original list in a new list that would be great!!!
thanks in advance!!!

New Topic/Question
Reply




MultiQuote




|