3

I am using pi as part of a Prolog program I am writing. Here is my only mention of pi in the whole program:

ArcDistance is ((Degree/ 360) * Diameter * pi).

However, when I run the program, I get the following error:

uncaught exception: error(type_error(evaluable,pi/0),(is)/2)

Am I doing anything wrong in terms of calling/using pi? Thanks for the help!

false
  • 10,264
  • 13
  • 101
  • 209
user1462294
  • 167
  • 4
  • 13

1 Answers1

3

In ISO-Prolog, that is, since Cor.2:2012, the atom pi is defined with the usual meaning.

Given the response of the system you showed, you seem to use an older version of GNU-Prolog like 1.3. However, it is defined in versions starting with at least 1.4.0.

pi is currently defined in IF, B, YAP GNU, SWI, and presumably many other systems.

false
  • 10,264
  • 13
  • 101
  • 209
  • Also defined in (recent versions of) CxProlog, ECLiPSe, Qu-Prolog, and XSB. I think also SICstus Prolog but my copy expired recently and I cannot confirm. – Paulo Moura Oct 27 '13 at 23:08
  • Thanks @false. At first, I wasn't sure it was defined in my GNU Prolog 1.4, but I had a minor case of operator error. – lurker Oct 28 '13 at 00:33
  • 1
    SICStus update: https://sicstus.sics.se/sicstus/docs/latest4/html/sicstus/ref_002dari_002daex.html . Quoting: "*pi   since release 4.3, ISO*". – repeat Dec 17 '15 at 15:44