I think [EMAIL PROTECTED] wrote:
[Charset iso-8859-1 unsupported, filtering to ASCII...]
> Hi all,
> 
> This might seem silly but I **really** cannot figure this one out.
> 
> Is there a jess command/function to convert a string to an integer?
> 
...
> I need to be able to convert the string "25" to an integer to be
> able to do some comparisons.
> ex (a ?x&:(= ?x 25))

Jess tries hard to convert things automatically between types, if it
can. So most of the time, you can just ignore type differences. For
instance, (+ 5 "25") gives 30. The only time types really matter is
when you want to directly pattern-match on a value; the
pattern-matcher compares both the value and type of a thing. The
"integer" function accepts any argument that can be converted to a
numeric type, and returns a value that really is an integer -- i.e.,
(integer "25") gives 25.

Now, in the little code example above, note that (= 25 "25") returns
TRUE -- the "25" is converted to a number automatically.  On the other
hand, (eq 25 "25") returns FALSE, because the two arguments are of
different types.

(Caveat: we're talking about Jess 6.1 here. If you've got an earlier
version, or a prerelease version, the behavior may be slightly
different.)

---------------------------------------------------------
Ernest Friedman-Hill  
Distributed Systems Research        Phone: (925) 294-2154
Sandia National Labs                FAX:   (925) 294-2234
PO Box 969, MS 9012                 [EMAIL PROTECTED]
Livermore, CA 94550         http://herzberg.ca.sandia.gov

--------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
in the BODY of a message to [EMAIL PROTECTED], NOT to the list
(use your own address!) List problems? Notify [EMAIL PROTECTED]
--------------------------------------------------------------------

Reply via email to