Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 9285ffa5f81d8ecc2d0bd0c30b7204b06f146066bf2348f24d20dc9d7ea7d74f
Ticket: 5a1aaa201da8bd4ba2b37348c5247c98d192321e
lsearch -stride with -subindices and -inline -all gives unexpected result
User & Date: juliannoble2 on 2024-11-13 03:41:51
Changes

  1. icomment:
    Aside from consistency with the nested equivalent, it's not self-consistent.
    
    Another way of looking at this is that -all should always be equivalent to building the list by iterating using -start.
    
      lsearch -start 0 -stride 2  -index 1  -inline -subindices {abc abc abc bcd abc cde abc def} *c*
        abc
    
      lsearch -start 2 -stride 2  -index 1  -inline -subindices {abc abc abc bcd abc cde abc def} *c*
        bcd
    
      lsearch -start 4 -stride 2  -index 1  -inline -subindices {abc abc abc bcd abc cde abc def} *c*
        cde
    
      lsearch -all -start 0 -stride 2  -index 1  -inline -subindices {abc abc abc bcd abc cde abc def} *c*
        abc abc abc bcd abc cde
    
    This should be: abc bcd cde
    but it's returning each matched stride-group instead.
    
    This result is already obtainable by omitting -subindices
    
      lsearch -all -start 0 -stride 2  -index 1  -inline {abc abc abc bcd abc cde abc def} *c*
        abc abc abc bcd abc cde
    
    
    I'm not aware of any case other than with a single -index combined with -stride, -subindices -all where this inconsistency occurs.
    
    There aren't many documented examples for -stride, and no test coverage for this specific case.
    It took me a while to understand there was an inconsistency, and although the -stride option has been available for a while - I think with the release of Tcl 9 this should be high on the priority list.
    
  2. login: "juliannoble2"
  3. mimetype: "text/plain"
  4. priority changed to: "8"