bug-prolog
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Bug, or at least something wrong


From: Paulo Moura
Subject: Re: Bug, or at least something wrong
Date: Mon, 22 Oct 2007 16:32:28 +0100


On 2007/10/21, at 20:44, Felipe Ignacio Canas Sabat wrote:

These are the commands I am using:

%%%%%%%%%%%%
even(X) :-
  A is X mod 2,
  A == 0.

odd(X) :-
  A is X mod 2,
  A == 1.

step(X,Y) :-
  X > 1,
  even(X),
  Y is X/2.

step(X,Y) :-
  X > 1,
  odd(X),
  Y is 3*X + 1.
%%%%%%%%%%%%

And this is what I'm running:

  | ?- step(32,X), step(X,Y), step(Y,Z).

And this is the error I get:

  uncaught exception: error(type_error(integer,16.0),(is)/2)

I don't get this error when I run it on SWI-prolog, and I really don't
see what the error is. This is the trace:

There is a bug in your code: you want integer division, not float division in the first clause of step/2.. GNU Prolog behavior is correct. SWI-Prolog is more forgiving. You may also use arithmetic equality (=:=/2) instead of term equality (==/2).

Cheers,

Paulo


-----------------------------------------------------------------
Paulo Jorge Lopes de Moura
Dep. of Computer Science, University of Beira Interior
6201-001 Covilhã, Portugal

Office 4.3  Ext. 3257
Phone: +351 275319891 Fax: +351 275319899
Email: <mailto:address@hidden>

Home page: <http://www.di.ubi.pt/~pmoura>
Research: <http://logtalk.org/>
-----------------------------------------------------------------







reply via email to

[Prev in Thread] Current Thread [Next in Thread]