Reputation: 1047
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.
Upvotes: 1
Views: 455
Reputation: 60004
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...
Upvotes: 2