当前位置: 动力学知识库 > 问答 > 编程问答 >

How to check whether a value is a numeric value in Prolog?

问题描述:

When someone enters a value (Year), I want to validate the value. I.e., I want to check whether the value is a numeric. I am new to Prolog. Can you help me with this.

Thanks in advance.

网友答案:

just write down - in Prolog - the rules that - under your judgment - define what a valid year must be. For example

valid_year(Y) :-
  integer(Y), Y > 0, Y =< 2014.

You can see from this snippet that your question is largely unspecified: what about future ? and far past ? What about other calendar systems (there are plenty) ?

In SWI-Prolog, there is extensive support for time and date, but I feel it is definitely beyond your current requirements...

分享给朋友:
您可能感兴趣的文章:
随机阅读: