문제

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