is
BAP Online Manuals : Library
Reference : Library by Name
: is
Previous: integer
Next: isname
BAP Online Manuals : Library Reference : Library by Name : is
Previous: integer
Next: isname
Previous: integer
Next: isname
6.2.74. is
evaluates a numeric expression
SYNOPSIS
OPERATOR op(700,xfx,is). is(Result,Term) Result is 3+20/4
SYNTAX
is(Result,Term) (x,i) Result is Term (x,i)
ARGUMENTS
integer(Result) (x) numeric value of the expression Term
void(Term) (i) a Term belonging to the arithmetic domain to be evaluated
DESCRIPTION
This is a standard prolog built-in. Succeeds if Result can be matched with the result of
interpreting term as an arithmetic expression. The following arithmetic expressions are legal:
'+','-','*','/', and 'mod'
For these expressions operators are declared:
op(500,yfx,"+"). op(500,fx,"+"). op(500,yfx,"-"). op(500,fx,"-"). op(400,yfx,"*"). op(400,yfx,"/"). op(300,xfx,"mod").The terms may be nested.
EXAMPLE
readln(Input), % e.g. enter "3+5", "4*6" fronttoken(Input,T1,,R1), fronttoken(R1,Op,T2), str_int(T1,I1),str_int(T2,I2), Expr =.. [Op,I1,I2], Sum is Expr, write(Sum),nl.
ERRORS
No runtime errors.
LAYERS
prolog-process, client-server, object
BAP Online Manuals : Library Reference : Library by Name : is
Previous: integer
Next: isname