From aikguitarist@usa.net  Mon Nov 20 00:07:00 2000
Received: from aw163.netaddress.usa.net (aw163.netaddress.usa.net [204.68.24.63])
	by swi.psy.uva.nl (8.9.3/8.9.3) with SMTP id AAA09235
	for <prolog@swi.psy.uva.nl>; Mon, 20 Nov 2000 00:06:59 +0100 (MET)
Received: (qmail 8532 invoked by uid 60001); 19 Nov 2000 23:06:58 -0000
Message-ID: <20001119230658.8531.qmail@aw163.netaddress.usa.net>
Received: from 204.68.24.63 by aw163 for [149.99.114.51] via web-mailer(34FM.0700.4.03) on Sun Nov 19 23:06:58 GMT 2000
Date: 19 Nov 00 18:06:58 EST
From: aikGuitarist <aikguitarist@usa.net>
To: prolog@swi.psy.uva.nl
Subject: arithmetic exception
X-Mailer: USANET web-mailer (34FM.0700.4.03)
Mime-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 8bit
X-MIME-Autoconverted: from quoted-printable to 8bit by swi.psy.uva.nl id AAA09235

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

