Checking for a value in a list
From: Mark J Fenbers (Mark.Fenbers_at_noaa.gov)
Date: 03/30/04
- Previous message: no-spam: "Re: Sublists question"
- Next in thread: Bill Spight: "Re: Checking for a value in a list"
- Reply: Bill Spight: "Re: Checking for a value in a list"
- Reply: no-spam: "Re: Checking for a value in a list"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Mon, 29 Mar 2004 18:57:55 -0500
I'm stumbling my first Prolog program. This fact will be obvious when
you read my question that follows...
I want to describe that a shift is considered "operational" if the shift
is among the given list of 'H', 'D', '6', 'HE', or 'E'. My code has
this:
operational(Shift) :-
equals(Shift,'H').
operational(Shift) :-
equals(Shift,'D').
operational(Shift) :-
equals(Shift,'6').
operational(Shift) :-
equals(Shift,'HE').
operational(Shift) :-
equals(Shift,'E').
I understand (perhaps incorrectly) that this code means
operational(Shift) if Shift equal 'H' or Shift equals 'D' or Shift
equals '6' or Shift equals 'HE' or Shift equals 'E'. I have a feeling
that this isn't the best way to check if Shift is among the given list.
What is a better way?
Mark
- Previous message: no-spam: "Re: Sublists question"
- Next in thread: Bill Spight: "Re: Checking for a value in a list"
- Reply: Bill Spight: "Re: Checking for a value in a list"
- Reply: no-spam: "Re: Checking for a value in a list"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]