Thursday, March 13, 2008

Modulo for Higher Values in Graphtalk

GraphTalk XO system is not able to handle the case wherein modulo for the higher values of variables of data type-Integers & Real is required. The inbuilt mod function fails to produce the required result and abruptly fails
The below code solves the problem

get_remainder (Para, Res) :-
[Amt, Step_amt] = :prop.getl (Para, [amt, step_amt]) &
get_rem (Amt, Step_amt, Res)
;

get_rem (Amt, Step_amt, Res) :-
if
Amt >= Step_amt
then
Rem = Amt - Step_amt
else
Rem = Amt &
If
Rem >= Step_amt
then
get_rem (Rem, Step_amt, Res)
else
Res = Rem;

No comments: