1. What is up with the 'FIND' function?

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 = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"

Further, I have a sequence - 'eRevision' - which contains a letter in the
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 following
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

new topic     » topic index » view message » categorize

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

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 = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ=
"
>
> Further, I have a sequence - 'eRevision' - which contains a letter in the
> 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 followin=
g
> 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
----------

new topic     » goto parent     » topic index » view message » categorize

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

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 message » categorize

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

Aaaaah! Match() is what I'm looking for! Thanks Patrick! :)


Patrick Barnes 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 = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ=
> "
> >
> > Further, I have a sequence - 'eRevision' - which contains a letter in the
> > 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 followin=
> g
> > 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
> ----------
> 
>

new topic     » goto parent     » topic index » view message » categorize

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

Well, seems that the match works out the way I wanted to anyway!

Thanks again! :)



Patrick Barnes wrote:
> 
> 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 message » categorize

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

Hi Ken,

This discrepancy arises because an atom is not equivalent to a one element
sequence
containing the same value. Therefore, to use your example, eRevision does not
contain
'c', but "c" (because it has been declared as a sequence). If you declare
eRevison
as an atom then 

eFindResult = find(eRevision, zALPHA)

will return 3, as required.

Alternatively you could replace the "find" function with "match", this finds a 
sequence as a SLICE of another sequence. So 

eFindResult = match(eRevision, zALPHA) 

will also return 3.

Not sure whether this has helped or made you more confused!

new topic     » goto parent     » topic index » view message » categorize

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

On Thu, 23 Mar 2006 21:24:42 +1100, Patrick Barnes <mrtrick at gmail.com>
wrote:

>
>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?
>
Apart from the fact that match(needle2 gives a type error...

Pete

new topic     » goto parent     » topic index » view message » categorize

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

Jules Davy wrote:
> 
> Hi Ken,
> 
> This discrepancy arises because an atom is not equivalent to a one element
> sequence
> containing the same value. Therefore, to use your example, eRevision does not
> contain
> 'c', but "c" (because it has been declared as a sequence). If you declare
> eRevison
> as an atom then 
> 
> eFindResult = find(eRevision, zALPHA)
> 
> will return 3, as required.
> 
> Alternatively you could replace the "find" function with "match", this finds
> a 
> sequence as a SLICE of another sequence. So 
> 
> eFindResult = match(eRevision, zALPHA) 
> 
> will also return 3.
> 
> Not sure whether this has helped or made you more confused!

new topic     » goto parent     » topic index » view message » categorize

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

Dang, sorry about that last post, pressed the button too early!

Anyway, Jules, I see your point. I know about the difference between
'c' and "c", but I didn't understand that it would make a difference
when my code problem arised. I see it now, though. In my example,
the FIND searches for a "c" (sequence format), but tries to match that
with each induvidual ATOM in zALPHA - which of course doesn't match.
(Hope I got it right, and didn't make an ass of myself. :))

Again, thanks to you and all for their feed backs.

Regards, Ken aka ZNorQ.

Jules Davy wrote:
> 
> Hi Ken,
> 
> This discrepancy arises because an atom is not equivalent to a one element
> sequence
> containing the same value. Therefore, to use your example, eRevision does not
> contain
> 'c', but "c" (because it has been declared as a sequence). If you declare
> eRevison
> as an atom then 
> 
> eFindResult = find(eRevision, zALPHA)
> 
> will return 3, as required.
> 
> Alternatively you could replace the "find" function with "match", this finds
> a 
> sequence as a SLICE of another sequence. So 
> 
> eFindResult = match(eRevision, zALPHA) 
> 
> will also return 3.
> 
> Not sure whether this has helped or made you more confused!

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu