Question

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?

Était-ce utile?

La solution

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
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top