Here's an approach.

>> cat: ["cat" "feline" "kitty" "lion"]
== ["cat" "feline" "kitty" "lion"]
>> fact: "I have a kitty"
== "I have a kitty"
>> foreach wrd parse fact none [if found? find  cat wrd [prin "found " print
wrd]]
found kitty
>>
This is a bit simplified.  If

>> fact: "My kitty cat ate a mouse."
== "My kitty cat ate a mouse."
>> foreach wrd parse fact none [if found? find  cat wrd [prin "found " print
wrd]]
found kitty
found cat
== false
>>
The == false is the result of words after the search words. Perhaps, in
place of 'if, 'either could be used with [] for the "else" action block.
Yeah!  That works!
Also if fact: "I have a kitty." it fails because the simple parse generates
["I" "have" "a" "kitty."]
Parse needs to be modified to dump the period.


Russell [EMAIL PROTECTED]
----- Original Message -----
From: <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, March 23, 2000 8:46 PM
Subject: [REBOL] Newbie question #2 - Pattern making and using? Re:


> Hi T Brownell
>
> you wrote:
> >x: none
> >cat: "feline"
> >cat: "kitty"
> >fact: "I have a kitty"
> >if found? find fact cat [x: "found it"]
> >if found? x [print x]
> >unset 'x
>
> A few remarks:
>
> >x: none
> this line is not necessary. But it's not a bad idea.
>
> >cat: "feline"
> >cat: "kitty"
>
> Now cat evaluates to "kitty" only! cat no longer evaluates to "feline"! If
> you try this code against fact: "I have a feline" find will fail!
>
> Given:
> >cat: "feline"
> >cat: "kitty"
> >fact: "I have a kitty"
>
> you could say:
> if found? find fact cat [print x: "found it"]
>
> >How can i make the 2 values of cat: into a pattern
> >that can be used in this script?  Also, the rest of
> >this script stinks... THERE MUST BE A BETTER WAY!!!
>
>

Reply via email to