Re: Sublist Pattern Matching
- From: "Geoffrey Summerhayes" <sRuEmMrOnVoEt@xxxxxxxxxxx>
- Date: Fri, 25 Nov 2005 13:51:03 -0500
"Ka0s" <tushar.saxena@xxxxxxxxx> wrote in message
news:1132903870.582959.204590@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> Hi All,
>
> I am having some trouble with a particular prolog query. Yes it is for
> an assignment, but I have been cracking my head for the past two days
> trying to figure it out, and in any case it is but a small part of a
> much larger assignment ;)
>
> The situation is this ........ I have a set of facts
>
> fact(fact1:1).
> fact(fact2:1).
> fact(fact3:1).
> fact(fact1:2).
> fact(fact2:2).
> fact(fact3:2).
> fact(fact1:3).
> fact(fact2:3).
> fact(fact3:3).
>
> As you can see, the facts match a particular pattern ... i.e.
> fact<n>:<x> ...... Given an input pattern (say Pattern or what you
> will), I need to construct a predicate testPattern(Pattern) that will
> return true if it can find a fact matching the input pattern.
>
> testPattern(Pattern) :- ???
>
> Note that this should be like a wildcard pattern match "Pattern*".
>
> Any help would be appreciated.
>
atom_chars/2 is your friend.
--
Geoff
.
- Follow-Ups:
- Re: Sublist Pattern Matching
- From: Ka0s
- Re: Sublist Pattern Matching
- References:
- Sublist Pattern Matching
- From: Ka0s
- Sublist Pattern Matching
- Prev by Date: Re: java calling prolog
- Next by Date: Re: java calling prolog
- Previous by thread: Re: Sublist Pattern Matching
- Next by thread: Re: Sublist Pattern Matching
- Index(es):