From: Kieran E. <kie...@or...> - 2009-07-13 09:23:20
|
Peter da Silva wrote: > > lsearch -index 0 -stride 2 would search the first subelement of every > second element. The default behavior of lsearch -stride would be "- > index {}". > What if one wants to search every (2n+1)th element? e.g. all the values in a {name value name value ...} list. There doesn't seem to be any way to achieve this with the proposal as it stands - despite being an important use case. It's also rather inconsistent with the -stride option I proposed for lsort; from TIP #326: If -stride is supplied, the list will be treated as consisting of groups of grpSize elements, and the groups will be sorted by either their first element or, if the -index option is used, by the element within each group given by the first index passed to -index (which is then ignored by -index). So to sort by the first subelement of every second element, one would do: lsort -stride 2 -index {0 0} To sort by the values in a {name value name value ...} list, one would do: lsort -stride 2 -index 1 If -index is not used, then lsort with -stride operates on the first element in each group; I guess this could be thought of as changing the default of -index to be 0 when -stride is used, though I didn't word it like that. Regards, Kieran Elby |