Subject: arithmetic exception

From: aikGuitarist <[email-masked]>
Date: 19 Nov 00 18:06:58 EST

This is a predicate numPos(List, N) that is supposed to return true if N is
the number of positive integers found in List which is a list, at the topmost
level. So 
  numPos([1,2,[3], 4], Something). 
should return 
  Something = 3;
  no

Here is my code:

numPos([], 0).
numPos([Head|Tail], N):-integer(Head), Head>0, X is N-1, numPos(Tail,X).
numPos([Head|Tail], N):-numPos(Tail,X).

Now look at this trace:

| ?- numPos([1,[2],3], 2).
   (0) Call: numPos([1,[2],3],2) ?
   (1) Call: integer(1) ?
   (1) Exit: integer(1) ?
   (2) Call: numPos([[2],3],1) ?
   (3) Call: integer([2]) ?
   (3) Fail: integer([2]) ?
   (4) Call: numPos([3],_134) ?
   (5) Call: integer(3) ?
   (5) Exit: integer(3) ?
! Arithmetic Exception
! Aborting...              

What is happening there I don't understand. Note that other such queries work
is [2] was at the end of the list in this list for example. 

____________________________________________________________________
Get free email and a permanent address at http://www.amexmail.com/?A=1