Unary and Binary Functions / Arithmetic Operations

PrologJ recognizes 17 unary and 12 binary arithmetic functions / operations in arithmetic expressions, such as those appearing in arguments of is/2 or the various arithmetic comparison predicates. Though some represent ISO additions to the list of permitted operations, all are considered part of the core and are always available in PrologJ. All are documented in [ Deransart, Ed-Dbali, and Cervoni 1996 ] chapter 6.

Unary Operations

Binary Operations

Notes

  1. In one case, the meaning of an arithmetic operator differs between traditional and ISO standard Prolog. In traditional Prolog, '/'/2 represents integer division. Thus, for example, in traditional Prolog 2 / 5 evaluates as 2. In ISO Prolog, '/'/2 represents real division, and a separate operator ('//'/2) is used for integer division. Thus, for example, in ISO Prolog 2 / 5 evaluates as 2.5, while 2 // 5 evaluates as 2.
     
    For compatibility with either standard, PrologJ utilizes the flag operator_single_slash. When the value of this flag is real, the operator is interpreted as meaning real division, as in the ISO standard. When the value of this flag is either, the operator is interpreted as meaning integer division if both operands are integers, else as meaning real division. (This is compatible with traditional Prolog, since traditional Prolog only supports integers.) The initial value of this flag is set to either if the -f[lags] t option is specified at system startup; else if is initialized to real. However, it can be changed at any time by using set_prolog_flag/2.
Copyright © 2005 - Russell C. Bjork. See the file See file COPYING in the root directory for copyright information.

Valid XHTML 1.0!