Re: What is up with the 'FIND' function?

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

wait, nevermind... that's not right:


constant haystack1 = { {1}, {2}, {3}, {4}, {5}, {6} }
constant haystack2 = { 1, 2, 3, 4, 5, 6 }
constant needle1 = {3}
constant needle2 = 3

? find( needle1, haystack1 ) -- 3
? match( needle1, haystack1 ) -- 0
? find( needle1, haystack2 ) -- 0
? match( needle1, haystack2 ) -- 3
? find( needle2, haystack1 ) -- 0
? match(needle2, haystack1 ) -- 0
? find( needle2, haystack2) -- 3
? match(needle2, haystack2) --0

Does that make more sense?



On 3/23/06, Patrick Barnes <mrtrick at gmail.com> wrote:
>
> You are confusing find() and match()...
> find() searches a sequence looking for an element...
> constant haystack1 = { {1}, {2}, {3}, {4}, {5}, {6} }
> constant haystack2 = { 1, 2, 3, 4, 5, 6 }
> constant needle1 = {3}
> constant needle2 = 3
>
> ? find( needle1, haystack1 ) --finds {3} within haystack1, prints 3
> ? match( needle2, haystack2 ) --finds a slice of haystack2 matching
> needle2, prints 3
>
> all other combinations will return 0.
>
>
> On 3/23/06, ZNorQ <guest at rapideuphoria.com> wrote:
> >
> >
> > posted by: ZNorQ <znorq at holhaug.com>
> >
> > Hey,
> >
> > I'm trying to get the 'FIND' function to use properly, but I just don't
> > get it to work the way I want it to.
> >
> > I have a string called zALPHA, containing all the letters in both upper
> > and lower case;
> >
> > constant zALPHA = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWX=
YZ"
> >
> > Further, I have a sequence - 'eRevision' - which contains a letter in t=
he
> > above range (Hence, the eRevision is of length 1, but still a sequence.=
).
> >
> > Lets say the eRevision sequence contains 'c', I'd think that the follow=
ing
> > function should return '3', but it returns '0' (Zero);
> >
> > eFindResult = find(eRevision, zALPHA)
> >
> > ..while THIS function returns the correct number;
> >
> > EFindResult = find(eRevision[1], zALPHA)
> >
> > Could someone please explain this to me?
> >
> > Regards, Kenneth 'ZNorQ' Nilsson
> >
> >
> --
> MrTrick
> ----------
>
>


--
MrTrick
----------

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

Search



Quick Links

User menu

Not signed in.

Misc Menu