1. RE: more match() problems
- Posted by Al Getz <Xaxo at aol.com> May 28, 2003
- 411 views
Mike Nelson wrote: > > > Derek Parnell wrote: > > <snip> > > match() LOOKS FOR SLICES - ALWAYS. > > find() LOOKS FOR ELEMENTS - ALWAYS. > </snip> > > This is entirely correct and is as it should be. I would further > emphasize > that find() and match() only work at the top level. > > Since match() always looks for slices, an atom as the first parameter is > and > should be an error. An empty sequence as the first parameter is also an > error--a return of 0 is preferable, as it would eliminate some special > case > checking from code using match(). > > -- Mike Nelson > > Hi Mike, I see your point. I really only wanted match to be able to do i=match("",sequence) --rets 0 That's really all i wanted. In every case i think i've ever used match, ive used a variable sequence as the first argument, so i guess im not as worried about having it allow an atom as the first argument as some other people might be. Take care, Al
2. RE: more match() problems
- Posted by Al Getz <Xaxo at aol.com> May 28, 2003
- 399 views
Derek Parnell wrote: > > > On Wed, 28 May 2003 07:43:20 +0000, Al Getz <Xaxo at aol.com> wrote: > > > > > Hello again, > > > > Looking closer at the match() function, > > i find that it doesnt really work very well > > unless you are only using it on one level sequences (like {1,2,3} or > > "abc"). > > > > Untill this point, i dont think i ever used it > > for anything else, but since we were looking at it > > anyway i thought i would mention this. > > > > match({2,3},{1,2,3}) > > > > returns the number 2, because the 'slice' was found > > in the second sequence. Works fine. > > > > Now, > > > > match({{1,2,3}},{{1,2,3}}) > > > > returns the number 1, because again the 'slice' (although this time > > deeper) was found in > > the second sequence. Works fine. > > > > Nowwwwwwwww... > > > > what does > > > > match({{2,3}},{{1,2,3}}) > > > > return? (same example with the 1 missing in first arg) > > > > If you said the number 2, you are correct, because > > the 'slice' could be found in the second sequence > > at the required level, right??? > > > > Well, guess again! > > The Eu match command returns a big fat zero! > > > > Yes, that's right, > > > > i=match({{1,2,3}},{{1,2,3}}) -- rets 1 > > but > > i=match({{2,3}},{{1,2,3}}) -- rets 0 > > > > > > Care to try to figure that out? > > Sure. Let's look at all the possible slices of {{1,2,3}}, shall we. > > s = {{1,2,3}} > Length of s is 1, right? > So then there is only one slice, namely s[1..1] and its value is > {{1,2,3}}. > > Now the LHS side of your match was {{2,3}}. Can you locate this value in > > any of the slices (all one of them) of s? > > > > I guess i went too far in assuming there was a method > > to the madness. > > > > Anomaly number 97316 and counting... > > Not an anomaly at all. I keep saying this but it doesn't seem to be > making > it across the language barrier... > > match() LOOKS FOR SLICES - ALWAYS. > find() LOOKS FOR ELEMENTS - ALWAYS. > > > -- > > cheers, > Derek Parnell > Yeah? no kiddin??? I realized i made the same mistake Kat made, but the post went through already, and there is no way to edit a post on Topica like there is in other message boards i post on. Once you hit that button, that's it. It's a shame it solicited a response, because that response was a wasted effort. Thanks anyway, Al
3. RE: more match() problems
- Posted by Al Getz <Xaxo at aol.com> May 28, 2003
- 407 views
Derek Parnell wrote: > > > On Wed, 28 May 2003 07:43:20 +0000, Al Getz <Xaxo at aol.com> wrote: > > > > > Hello again, > > > > Looking closer at the match() function, > > i find that it doesnt really work very well > > unless you are only using it on one level sequences (like {1,2,3} or > > "abc"). > > > > Untill this point, i dont think i ever used it > > for anything else, but since we were looking at it > > anyway i thought i would mention this. > > > > match({2,3},{1,2,3}) > > > > returns the number 2, because the 'slice' was found > > in the second sequence. Works fine. > > > > Now, > > > > match({{1,2,3}},{{1,2,3}}) > > > > returns the number 1, because again the 'slice' (although this time > > deeper) was found in > > the second sequence. Works fine. > > > > Nowwwwwwwww... > > > > what does > > > > match({{2,3}},{{1,2,3}}) > > > > return? (same example with the 1 missing in first arg) > > > > If you said the number 2, you are correct, because > > the 'slice' could be found in the second sequence > > at the required level, right??? > > > > Well, guess again! > > The Eu match command returns a big fat zero! > > > > Yes, that's right, > > > > i=match({{1,2,3}},{{1,2,3}}) -- rets 1 > > but > > i=match({{2,3}},{{1,2,3}}) -- rets 0 > > > > > > Care to try to figure that out? > > Sure. Let's look at all the possible slices of {{1,2,3}}, shall we. > > s = {{1,2,3}} > Length of s is 1, right? > So then there is only one slice, namely s[1..1] and its value is > {{1,2,3}}. > > Now the LHS side of your match was {{2,3}}. Can you locate this value in > > any of the slices (all one of them) of s? > > > > I guess i went too far in assuming there was a method > > to the madness. > > > > Anomaly number 97316 and counting... > > Not an anomaly at all. I keep saying this but it doesn't seem to be > making > it across the language barrier... > > match() LOOKS FOR SLICES - ALWAYS. > find() LOOKS FOR ELEMENTS - ALWAYS. > > > -- > > cheers, > Derek Parnell > Yeah? no kiddin??? I realized i made the same mistake Kat made, but the post went through already, and there is no way to edit a post like there is in other message boards i post on. Once you hit that button, that's it. It's a shame it solicited a response, because that response was a wasted effort. Thanks anyway, Al
4. RE: more match() problems
- Posted by gertie at visionsix.com May 28, 2003
- 407 views
On 28 May 2003, at 18:05, Al Getz wrote: <snip> > > > I guess i went too far in assuming there was a method > > > to the madness. > > > > > > Anomaly number 97316 and counting... > > > > Not an anomaly at all. I keep saying this but it doesn't seem to be > > making > > it across the language barrier... > > > > match() LOOKS FOR SLICES - ALWAYS. > > find() LOOKS FOR ELEMENTS - ALWAYS. > > > > > > -- > > > > cheers, > > Derek Parnell > > > > Yeah? no kiddin??? > > I realized i made the same mistake Kat made, but > the post went through already, and there is no > way to edit a post on Topica like there is in other > message boards i post on. Once you hit that > button, that's it. How i'd like to see it happen isn't a mistake. Presuming it would actually behave that way would be a mistake. Rather like the news report here: "you don't expect government employees to mistreat you on the phone", but i do expect that. I don't think it's right that they do, but i expect them to. > It's a shame it solicited a response, because > that response was a wasted effort. Was not wasted! Other replies were generated, there may be a consensus that match(atom,sequence) should fall thru to find(). Besides, Derek has a way with that south hemisphere english that is clearer than Canadian sometimes. Kat
5. RE: more match() problems
- Posted by gertie at visionsix.com May 28, 2003
- 411 views
On 28 May 2003, at 18:14, Al Getz wrote: > > > Mike Nelson wrote: > > > > > > Derek Parnell wrote: > > > > <snip> > > > match() LOOKS FOR SLICES - ALWAYS. > > > find() LOOKS FOR ELEMENTS - ALWAYS. > > </snip> > > > > This is entirely correct and is as it should be. I would further > > emphasize > > that find() and match() only work at the top level. > > > > Since match() always looks for slices, an atom as the first parameter is and > > should be an error. An empty sequence as the first parameter is also an > > error--a return of 0 is preferable, as it would eliminate some special case > > checking from code using match(). > > > > -- Mike Nelson > > > > > Hi Mike, > > I see your point. > > I really only wanted match to be able to do > i=match("",sequence) --rets 0 > > That's really all i wanted. Me to, everything else would be gravey. > In every case i think i've ever used match, ive used > a variable sequence as the first argument, so i guess im > not as worried about having it allow an atom as the first > argument as some other people might be. I always do something like this: if atom(x) then z = match({x},y) else z = match(x,y) end if or if sequence(x) then z = match(x,y) else exit -- cannot use a goto eoroutine here! end if If i don't, sure as heck x will be "" eventually and the app will crash. Testing for equal(x,"") or (length(x) = 0 ) repeatedly, over and over, ad nauseum helps(?) too. Kat