Re: match() in depth!
- Posted by Kat <gertie at PELL.NET> Feb 24, 2002
- 411 views
On 25 Feb 2002, at 14:01, Derek Parnell wrote: > > Hi Kat, > I'm not quite sure what you are driving at either. > > When you run this code of yours, what do you get displayed? > > When I run it, it only reports that 'is' is found. And this is exactly what I > would have expected. > > My assumption is that 'parse()' converts : > > "this is a test of match()" > > to: > > {"this","is","a","test","of","match()"} Correct. > In which case the match({"is"},test) call will return 2. Because "is" is the > second element of the test sequence. > In which case the match({"s"},test) call will return 0. Because "s" is not any > of the elements in the test sequence. > > What did you find surprising with your test? I had never seen the match({"is"},test) in any code i have read in the archives. I have seen match("is",test). Frankly, the use of {} occasionally confuses me, and to put the "is" inside the { } told me it was a nested sequence, and should have returned nothing, zero, or an error,, because the help files say all the parms for match() are to be sequences, and a nested seq as the first parm barely makes sence. But i was looking for a way to get some code running faster, and tried it. Kat > ------ > Derek. > > > 25/02/2002 1:43:42 PM, Kat <gertie at PELL.NET> wrote: > > > > >On 24 Feb 2002, at 22:52, rforno at tutopia.com wrote: > > > >> > >> OK. But what is the strange thing about it? I don't understand. > > > >The {bracketed} and "quoted" parts in the examples below. > > > >Kat > > > > > >> ----- Original Message ----- > >> From: "Kat" <gertie at PELL.NET> > >> To: "EUforum" <EUforum at topica.com> > >> Sent: Sunday, February 24, 2002 12:49 AM > >> Subject: match() in depth! > >> > >> > >> > I didn't know we could do this! > >> > > >> > include strtok.e > >> > with trace > >> > sequence test > >> > > >> > test = "this is a test of match()" > >> > test = parse(test,32) > >> > > >> > > >> > if match({"is"},test) then > >> > puts(1,"found is\n") > >> > end if > >> > > >> > if match({"s"},test) then > >> > puts(1,"found s\n") > >> > end if > >> > > >> > trace(1) > >> > abort(0) > >> > > >> > > --------- > Cheers, > Derek Parnell > > > >