Ferret-2742
Ferret-2742

Reputation: 25

How to have a fact have multiple values in prolog?

I am wondering how I can make a fact have multiple values for example:

answer(1-100, 'yes').
answer(100-700, 'no).

For 1-100 it would be yes and 100-700 it would be no. Writing thousands of facts would be too time consuming.

Upvotes: 1

Views: 158

Answers (1)

Nicholas Carey
Nicholas Carey

Reputation: 74197

See the documentation for between/3:

answer( N , yes ) :- between(   1 , 100 < N ).
answer( N , no  ) :- between( 101 , 700 , N ).

Because life is too short to repeat the same thing over and over and over.

Upvotes: 1

Related Questions