Indexing ... (was: Thoughts about the controversial {expand} feature)



Fredderic <put_my_name_here@xxxxxxxxxxxxxxx> wrote:
Oh, there is one point that just came to mind. There's talk of
extending the end-n notation in [lindex] and [lrange] (and others) for
general substitution and offset. It's mostly in the spirit of those
changes that I originally started arguing this thread.

I likewise appreciate the idea, and will most certainly find it very
useful, but am none the less hoping [lindex] doesn't start supporting
$a-$b*$c+$d as its index. :)

Afaik, this is limited to single "+" and "-" operations with
possibly signed arguments. e.g -5+42, 2--4, ...

There are two things I'd like to see for lrange:

1.) allow to give more ranges, that are concat'ed
[lrange {a b c d e} 0 1 3 4] -> {a b d e}
2.) allow "relative" end-indices:
[lrange {a b c d e} 2 s+1] -> {c d}
"s" being an anchor like "end", but referring to the
previously given start-index. Based on my own code,
this would not only save lots of [expr]'ing already,
but also lots of intermediate saving to vars:
set v [...]; ... [lrange $list $var [expr {$var+42}]];

PS: this subthread is no longer about tcl-syntax.
.



Relevant Pages

  • Re: sectional results?
    ... integrity of ultimate and spirit> of the game. ... Everyone arguing this, keep telling yourself that. ...
    (rec.sport.disc)
  • Re: a "group question"
    ... pleased by "a group of men is waiting in your office" will ... feel uneasy with "a group of men was arguing in the street." ... of men was arguing in the street" or, for another example, "The jury ... The spirit of democracy cannot be imposed from without. ...
    (alt.usage.english)
  • Re: Future Anti-troll
    ... Tim wrote: ... Now where did I leave the popcorn? ... I offer it purely in the spirit of research. ... arguing over it with anyone, ...
    (uk.rec.motorcycles)