IF Computer > MINERVA > Manual > Reference > Arithmetic

Arithmetic

MINERVA
ifcomputer logo
f
Expert Services on the Web

New arithmetic functions programmed in MINERVA are used exactly as built in functions.

This allows both functional and relational notations for arithmetic expressions.

MINERVA predicates for arithmetic evaluation, e.g. is/2 used on a function like "Result = f(A,...,N)" will search for a predicate "f(A,...,N,Result)".

Thus arithmetic in MINERVA becomes easier to read and uses aggresive variable hiding.

% example: compute the cost for industrial urethane foam

% notation as relations a(Price) :- height(H), width(W), depth(D), unit_price_per_volume(U), Price is H * W * D * U.

% notation as functions

b(Price) :- Price is height * width * depth * unit_price_per_volume.

% uniform notation of functions resp. data base

height(6). depth(38). width(75). unit_price_per_volume(0.01).

Here is the result for the above program:

?- a(Price).

Price = 171.0

yes

?- b(Price).

Price = 171.0

yes

?-

document: http://www.ifcomputer.co.jp/MINERVA/Manual/Reference/Arithmetic/print_de.html
published 2008/8/25 update 2002/3/20 (c) 1996-2006 IF Computer Japan
IF Computer 5-28-2 Sendagi, Bunkyo-ku Tel +81-3-5814-3352 start (AT) ifcomputer.com
Customer Support Tokyo 113-0022 Japan   http://www.ifcomputer.com
Back> managed with ubiCMS