Re: Basic Question: Comparision and Arithmetic operators

Thomas Russ <[email protected]>
Newsgroups gmane.comp.ai.powerloom
Message-ID <[email protected]>
On Nov 3, 2004, at 3:28 PM, kolli kavita wrote:

> hi,
>
> could someone help me solving this. Are there any
> comparison operators like <,>,=.....(like 30<45) and
> so on. I need to use the difference of two numbers in
> the command. Does powerloom support such arithmetic
> operations. If someone knows the answer please let me
> know and please provide me with an example too if its
> not too much.

Yes, these operations are built in.  Like the rest of
PowerLoom, prefix notation is used.  Arithmetic operations
are actually implemented as constraints, so a single
unbound variable in any position is supported.

If you look at the number of employees section of the
tutorial in the PowerLoom manual, you will also see some
sections on the arithmetic comparisons.

Examples follow:


|= (ask (< 40 50))

Processing check-types agenda...
TRUE

|= (ask (< 50 40))

FALSE

|= (ask (+ 2 2 4))

TRUE

|= (ask (+ 2 2 5))

FALSE

|= (retrieve (+ 2 2 ?x))

There is 1 solution so far:
   #1: ?X=4

|= (retrieve (+ 2 ?x 4))

There is 1 solution so far:
   #1: ?X=2

|= (retrieve (+ ?x 5 4))

There is 1 solution so far:
   #1: ?X=-1

|= (deffunction age (?x ?y))

|f|AGE

|= (assert (age bill 12))

|P|(= (AGE BILL) 12)

|= (assert (age fred 15))

|P|(= (AGE FRED) 15)

|= (ask (> (age bill) (age fred)))

FALSE
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.