>> tcl has a set of wonderful "list" commands? all starting with "l"? but ONE command seems to be missing.
>>
>> usage: lfilter list repeat-range repeat-index...
>>
>> goal: to get a sublist out of a tcl list with repeats
>>
>> example 1:
>>
>> set mylist {a 1 b 2 c 3}
>>> range = "2" -> "a 1" or "b 2" or "c 3"
>>
>> lfilter $mylist 2 1
>>> 1 2 3
>>
>> example 1 would be a replacement for
>>
>> set ret [list]
>> foreach {dummy elm} $mylist {
>> lappend ret $elm
>> }
>>
>> repeat-range => {dummy elm}
>> repeat-index => elm
>>
>>
>> => all this can be expanded to sublists as well?
>
> Sounds great, TIP it and provide a reference implementation in the TIP!
To the OP, I would also recommend not calling it lfilter. When I see
lfilter I think it should be doing something like what the current lmap
does, pass the elements through a bit of code, only where the bit of
code 'filters' out certian elements based upon a condition. So your
example would simply be a filter on a list where the remainder after
dividing the list index value of the element by 2 is 1. Your example
would be an "lextract" to me, but not a full generic 'filter', which is
what I think a function named 'filter' should be doing, generic
filtering, not a specific particular subset of 'filtering'.