#20 negative indices for [list split]

open
nobody
puredata (65)
5
2005-11-15
2005-11-15
Frank Barknecht
No

Hi,

I would really like to see if the split operation of
[list] would also accept negative indices to split a
list at a point searched from the end of a list.

I implemented this in the [list-splat] abstraction,
which is in abstractions/footils/list-abs/, however to
do this, I needed to revers the list several times,
which can be a performance problem, if lots of lists
need to be processed.

Splitting at negative indices feels like a natural
operation, and it will probably not break (m)any
existing patches.

Ciao
--
Frank

Discussion

  • Logged In: YES
    user_id=569446

    Attached is a little patch which implements negative
    indices. Beware: I'm no C programmer, pointers scare me, it
    might crash your system. It didn't crash mine, though.

     
  • implements neg. split points for list split.

     
    Attachments
  • Logged In: YES
    user_id=801174

    btw, here's what i know as precedents to that feature:

    Ruby has this convention that negative indices only mean
    exactly the same as adding the length of the list to them,
    so, e.g. trying to access myArray[-x] is exactly like
    trying to access myArray[myArray.length-x].

    I think it's the same in Python (which, afaik, introduced
    the feature).

    GridFlow sometimes follow the Ruby convention, sometimes an
    extension of it (in which *all* out-of-bounds accesses are
    wrapped back in by using modulo)

     


Anonymous


Cancel   Add attachments