RE: match() (not short, he he)
- Posted by Christian.CUVIER at agriculture.gouv.fr May 27, 2003
- 417 views
> On 27 May 2003, at 11:16, Al Getz wrote: > > >> Hello again Kat, >> >> >> >Kat wrote: >> >match("b",{{"a","b","c"}}) -- 0 >> >There you simply have it nested too deeply. And you know that. >> > > >> Yes i know that and you know that, but the language doesnt. > > > It doesn't??? When i run it, it returns zero! And it should return zero! If > your's > doesn't, you better contact Rob, your interpreter has a bug somewhere! > > >> It doesnt matter how deeply you nest something, the >> language has to have a way of conveying the result to the >> program that makes sense for ALL possible cases, not just >> some... > > > That doesn't mean it should give errors! > > >> i=match("b","abc"}}) -- ret 2 > > > I say no. The b in "abc" looks like an atom to me, and you told match to look > for a "b", which is a sequence. > > >> i=match("b",{"a","b","c"}) --ret 2 > > > Yes. > > >> i=match("b",{{"a","b","c"}}) --ret 2 >> i=match("b",{{{"a","b","c"}}}) --ret 2 > > > No, and no. > I agree with all 4 statements: only #2 shoud return 2, all others 0. And it means that, contrary to what I said before, match() must behave differently if first argument is an atom or a sequence. But logically it shouldn't throw an error when first arg is an atom. Thus i=match('b',"abc") --ret 2 which means that match() falls back on find() in this case. CChris