0

I have a list of numbers and I have to calculate the sum of the Even numbers and the product of the Odd numbers of the same list. I'm new in prolog and this is my code so far:

l_odd_even([],0).
l_odd_even([H|T], Odd, [H|Etail], Sum) :-
    H rem 2 =:=0,
    split(T, Odd, Etail),
    Sum = H + Etail.
l_odd_even([H|T], [H|Otail], Even, Prod) :-
    H rem 2 =:=1,
    split(T, Otail, Even),
    Prod = H * Otail.

Can anyone help me here ? And I'd like some examples in order to test if the code works.

false
  • 10,264
  • 13
  • 101
  • 209
Rares
  • 33
  • 1
  • 4

0 Answers0