Re: match() in depth!

new topic     » goto parent     » topic index » view thread      » older message » newer message

----- Original Message -----
From: <bensler at mail.com>
To: "EUforum" <EUforum at topica.com>
Subject: RE: match() in depth!


>
> > > If we use some symbolic representation of the test sequence above it
> > > could be
> > > coded as :
> > >
> > >  {TIAtOM}
> > >
> > > where I've simple replaced each word with a letter representing that
> > > word.
> > >
> > > Thus the find for "is" similarly coded is match({I}, test). This will
> > > return 2.
>
>
> {TIAtOM} = parse("this is a test of match()",32}
> ^ this should really be {T,I,A,T,O,M}
>

Not really. I was using SYMBOLS, not Euphoria!  I was trying to describe a
list of unique words, repesented by single letters.

  T === this
  I === is
  A === a
  t === test
  O === of
  M === match()

The string of letters TIAtOM is NOT a Euphoria variable - it is just a list
of symbols.

I represented this list of words as concatenated symbols enclosed in braces.
Sorry for the confusion.

In the first "match" we were looking for the word "is", which I had
represented by the symbol I. Thus I wrote :

    match(I, test) would return 2 because I is the second symbol in the list
TIAtOM

the second match was looking for the word "s", which I decided to represent
with the symbol S.

This is not a Euphoria variable. It is just a symbol representing the word
"s".

Thus match(S, test) would return 0 because S is not one of the symbols in
the list TIAtOM

Now if we rewrite this, substituting the words for the symbols...

  match("is", {"this","is","a","test","of","match()"}) ==> 2

  match("i", {"this","is","a","test","of","match()"}) ==> 0

> I = "is"
> I[1] = 'i'
>
> > > The scan for the "s" word is coded match({S},test) and returns 0
because
> > > there
> > > is no "s" word in the test sequence.
> >
>
> This is a bit confusing. match({S},test) will not return 0, it will fail
> with "variable not defined", because there is no S variable.
>
> > You lost me there. You said match({I}, test), which i understand, but
> > that is
> > {I}, same as "I", which meets the specs for match() in the help files. I
> > used
> > {"I"}.
>
> {I} != "I"
> {I} = {"is"}
> {"I"} = {{'I'}} -- (confused again? :P)
>
>

It seems that to get a faster match() or find(), we would need to specify a
starting point rather than the hardcoded starting index of 1.

  findfrom(10, "ai", "the rain in spain falls mainly in the plains") ==> 15

to do this sort of thing in current Euphoria, we have to get it to create
temporary slices, which is really just an unneccessary overhead.

--------
Derek.

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu