lsearch -start inconsistent return
Closed / Fixed1374778fffffffffffffffffffffffffffffffffCreated 21 years agoUpdated 21 years ago
Descriptionplain2005-12-06 20:33:02
The return for
lsearch -start X $list Value
is different when X >= end
and Value is the last or non-last list element.
set l {a b c d a b c d}
lsearch -start 5 $l d
returns 7, as expected
lsearch -start 999 $l d
returns 7
lsearch -start 999 $l c
returns -1
dkf Ticket [1374778fff]: 1 change
[History diff]2005-12-08 15:56:02
dkfplain2005-12-08 15:56:03
Logged In: YES user_id=79902 Any opinion on whether to fix this for 8.4 or 8.5? Or should it just be closed as "meant to work that way"? Please assign back to me with the comment.
dgpplain2005-12-08 23:58:55
Logged In: YES user_id=80530 I would expect that lsearch -start $x $l $i with $x an integer would either return -1 (not found) or would return an integer greater than or equal to $x . [lsearch -start 999 $l d] => 7 goes against my expectations, and suggests the search did not start at index 999 as instructed, but started at index 7 instead. This looks like a bug to me, and as such ought to be fixed for 8.4.13. I'm willing to be talked out of that if this "feature" enables some particularly elegant coding of some particularly useful algorithm. In that case, I'd want really good documentation.
dkfplain2005-12-09 21:40:24
Logged In: YES user_id=79902 Fixed in HEAD and 8.4 branch (looking off the end of a list always finds nothing)
Log in (anonymous is fine) to add a comment.