I have a assignment in JESS (Java Expert System Shell) and I'm having some trouble with it.

I'm trying to check if a certain variable (read from the keyboard) is a positive integer (I have already managed to check if it is positive) but I can't find a way (or a function) to check if the variable is an integer/number.

I tried the functions intergerp and numberp but these don't seem to work.

Can someone help me with this?

有帮助吗?

解决方案

integerp is, indeed, the way to check if something is an integer, as you can see in the transcript below.

Jess> (bind ?x (read))
1
1
Jess> (integerp ?x)
TRUE
Jess> (bind ?y (read))
foo
foo
Jess> (integerp ?y)
FALSE
Jess> (bind ?z (read))
1.1
1.1
Jess> (integerp ?z)
FALSE
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top