title: Prolog - Finding even elements in a list
body: <p>I want to write a rule in Prolog that returns the even elements in a given list. For example:
  even_elements([1,2,3,4], Result) would return Result: [2,4]</p>
  
  <p>Here is what I have so far:</p>
  
  <pre><code>% This is my base case.
  even_elements([H|T], Result) :- (0 is mod(H,2) -&gt; Result = [H|T] ; Result = T). 
  
  % This is my recursion.
  even_elements([H|T], [H|NT]) :- even_elements(T, NT).
  </code></pre>
  
  <p>The base case works properly and eliminates the first element if it is odd; but the recursion doesn't change anything. Any tips on how to complete the recursion is appreciated.</p>