title: Prolog not a function errors
body: <p>I'm a student in a class where we briefly are looking at several programming languages and have to make small programs with some of them. We are using Prolog this time. It's my first time ever with Prolog, and I am so confused (I'm used to Java or C#). </p>
  
  <p>I completed the first program, but the second one we have to do says "Create a program in which P(X) is true if X is a list containing n a's followed by n b's for some integer n". (P([a, a, b, b]) would be true while P([a, b, b]) would be false).</p>
  
  <p>my idea was this: P(X) will check and be sure X is a list, and that X is even (if it's an odd length, it will never be true). Then it calls another fact check "check_element" where if it is less than half way through the list, it checks for a's, if it is over half way, it checks for b's.</p>
  
  <p>This is my code: </p>
  
  <pre><code>check_element([], len, count). %Terminate, list is empty
  check_element([H|T], len, count) :- count =&lt; len/2, H == a, 
                                          count0 is count + 1, check_element(T, len, count0);
                                          count &gt; len/2, H == b,
                                          count0 is count + 1, check_element(T, len, count0).
  p(X) :- is_list(X), length(X, len),
          mod(len/2) =:= 0, %Makes sure length is even. If odd, auto fail.
          check_element(X, len, 1).
  </code></pre>
  
  <p>I get the following errors:</p>
  
  <p>Arithmetic: `count' is not a function</p>
  
  <p>Arithmetic: `mod(len/2)' is not a function</p>
  
  <p>Can someone please help me figure out what I'm doing wrong?</p>