Skip to content

Instantly share code, notes, and snippets.

@Irene-24
Created July 13, 2021 07:30
Show Gist options
  • Save Irene-24/d7b8ea0b4c6a992dac27e37227f8ee4b to your computer and use it in GitHub Desktop.
Save Irene-24/d7b8ea0b4c6a992dac27e37227f8ee4b to your computer and use it in GitHub Desktop.
isEven(N):-
0 is mod(N,2).
countEvenOdd([],[0,0]).
countEvenOdd([H|C],[Even,Odd]):-
countEvenOdd(C,[E,O]),
( isEven(H) ->
Even is E+1,Odd is O+0;
Even is E+0, Odd is O+1
).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment