Re: How can it be?!



Googie wrote:
See code and execution results below, then please, explain how is it
possible?

Some things to keep in mind:

The "in" operator is equivalent to [lsearch -exact].

This is different from the default [lsearch] which is
[lsearch -glob].

This is also different from the "==" operator which tests
equality with a bias toward numeric equality over string
identity.

See if those can explain what you see, since after a quick
glance, it appears you've left out details with which I
could offer a more specific explanation of your results.


set tokenAfterEndIndex [lsearch $topAllTokens $endToken]
if {$tokenAfterEndIndex == -1} {
puts "expr in: [expr {$endToken in $topAllTokens}]"
puts "lsearch: [lsearch $topAllTokens $endToken]"
foreach token $topAllTokens {
if {[expr {$token == $endToken}]} {
binary scan $token c* buf1
binary scan $endToken c* buf2
puts "bin1: $buf1"
puts "bin2: $buf2"
}
}
}


Results:

expr in: 1
lsearch: -1 <---- this is wrong!
bin1: 79 84 72 69 82 32 123 91 116 105 116 108 101 93 125 32 55 32 49
51
bin2: 79 84 72 69 82 32 123 91 116 105 116 108 101 93 125 32 55 32 49
51


--
| Don Porter Mathematical and Computational Sciences Division |
| donald.porter@xxxxxxxx Information Technology Laboratory |
| http://math.nist.gov/~DPorter/ NIST |
|______________________________________________________________________|
.