previous up contents next
Left: Count Up: Arithmetic functions Right: Sum

APU

APU (Arithmetic Processing Unit) evaluates an arithmetic expression encoded as a DATR path.

    APU:< ( 1 + 2 ) ^ 3 > = 27.
    APU:< ( ( 1 + 2 ) ^ 3 ) / ( 3 ^ 2 ) > = 3 .
    APU:< ( ( 1 + 2 ) ^ 3 ) / ( 3 ^ 2 ) ducks> = 3 ducks.

The APU function simply hands a path prefix, assumed to be an arithmetic expression, over to the implementation language for evaluation. It isn't realistic to expect to be able to agree a standard syntax for the arithmetic expressions - one might as well just accept that implementers will use something (near-) identical to that employed by the language of implementation. For doing sophisticated stuff there may well be no option but to invoke this function even though the price to be paid is that other people won't be able to run the code without replacing the APU invocations. For simpler stuff, our hope is that the standard functions that follow can be used. If they are sufficient, then they should always be used in preference to APU since they will be portable.


---------------------------------------------------------

Copyright © Roger Evans, Gerald Gazdar & Bill Keller, Tuesday 10 November 1998