This is really at a more plebeian level than much of the good
discussion that's gone on here recently, but dealing with it has
cost me SO much time...
What I would like is for Jess to treat atoms that happen to be
the equivalents of integers, as if they were numbers, when necessary.
That is, Jess shouldn't object that it is not a number, when doing
something numerical. So, for example, I would like it not to complain
about the following:
Jess> (<= 0 (sym-cat 1))
Rete Exception in routine Value::numericValue.
Message: Not a number: 1 type = 1 at line 2: ( <= 0 ( sym-cat 1 ) ) .
at jess.Value.numericValue(Value.java:123)
at jess._lt_or_eq.call(Funcall.java:1204)
at jess.Funcall.simpleExecute(Funcall.java:315)
at jess.Funcall.execute(Funcall.java:272)
at jess.Funcall.execute(Funcall.java:188)
at jess.Jesp.parseSexp(Jesp.java:139)
at jess.Jesp.parse(Jesp.java:56)
at jess.Main.main(Main.java:224)
Conversely, I'd like it to treat a number as an atom, when appropriate.
For example, not to complain about the following:
Jess> (implode$ (create$ "aaa" (+ 1 1) "bbb"))
Rete Exception in routine Value::stringValue.
Message: Not a string: 2 type = 4 at line 1: ( implode$ ( create$ "aaa" ( + 1 1 )
"bbb" ) ) .
at jess.Value.stringValue(Value.java:162)
at jess.implodemf.call(MultiFunctions.java:137)
at jess.Funcall.simpleExecute(Funcall.java:315)
at jess.Funcall.execute(Funcall.java:272)
at jess.Funcall.execute(Funcall.java:188)
at jess.Jesp.parseSexp(Jesp.java:139)
at jess.Jesp.parse(Jesp.java:56)
at jess.Main.main(Main.java:224)
These two examples are derived from a situation I've actually encountered,
i.e., I have this list with some numbers in it (as well as other stuff),
and the list has to be imploded at one point, but also the numeric items
in the list have to be compared with other numbers, at another point.
Of course, I can get around this by leaving it as a number and converting
it to a symbol, with sym-cat, when necessary. However, I'm working with
a very complex piece of code, and determining all circumstances when it
is necessary has not been easy. In CLIPS, which this system was originally
written for, the problem did not exist.
The situation is made a little more difficult because, as far as I can
tell, there isn't a built-in sym2num function to allow me to go the other
way. Doing this as a user function seems like overkill.
Anyway, I have a number of other such issues, most of which I've been
able to get around by writing little deffunctions. But this one is
particularly vexing given the code I'm working with.
Cheers,
Sidney
---------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
in the BODY of a message to [EMAIL PROTECTED], NOT to the
list. List problems? Notify [EMAIL PROTECTED]
---------------------------------------------------------------------