How can I write a rule that finds a number using integer/1?

Viewed 351

I am writing a rule that is looking for a particular integer. I assumed I can write something like this

find_number(X):-
    integer(X),
    X > 1, X < 5.

Then expect the result of a query to integer(X) to result in X=2, X=3, X=4, false. Instead, I just get a false result. The only way I found to write this rule is to use numlist/3 like so

find_number(X):-
    numlist(2, 4, NumList),
    member(X, NumList).

Can anyone explain why this is?

2 Answers
Related