Hi,
I want to include an abstraction into [list]-abs which acts as a wrapper around [list split] but also accepts negative indices to split off a list from the back. That is, a "list 0 1 2 3 4" splitted at index "-2" would give two lists, "0 1 2" and "3 4".
While this is no problem to implement, I'm still undecided about, how I should order the outlets of this abstractions?
To recapitulate: Currently the standard [list split 2] would send "0 1" to the first outlet and "2 3 4" to the second.
Should a fictional [list split -2] send "3 4" to the first or to the second outlet?
(Note: I tend to prefer sendign "3 4" to the first outlet, as it's technically easier, but I would like your opinions, too.)
Frank Barknecht _ ______footils.org_ __goto10.org__
Hallo, Frank Barknecht hat gesagt: // Frank Barknecht wrote:
(Note: I tend to prefer sendign "3 4" to the first outlet, as it's technically easier, but I would like your opinions, too.)
Note 2: Logically I tend to prefer it the other way around, as it makes it easier for example to allow negative rotations of lists.
Frank Barknecht _ ______footils.org_ __goto10.org__
Frank Barknecht wrote:
Hallo, Frank Barknecht hat gesagt: // Frank Barknecht wrote:
(Note: I tend to prefer sendign "3 4" to the first outlet, as it's technically easier, but I would like your opinions, too.)
Note 2: Logically I tend to prefer it the other way around, as it makes it easier for example to allow negative rotations of lists.
that is why [niagara] works like this.
i (being zexy) would prefer the [niagara] way of splitting lists at negative indices. btw, i just wanted to start to implement niagara as an abstraction based on [list]. i will not do it now...(but rather wait)
mfg.asdr. IOhannes
On Wed, 2 Nov 2005, Frank Barknecht wrote:
I want to include an abstraction into [list]-abs which acts as a wrapper around [list split] but also accepts negative indices to split off a list from the back. That is, a "list 0 1 2 3 4" splitted at index "-2" would give two lists, "0 1 2" and "3 4".
Negative indices have a precedent in both Ruby and Python. Also, many GridFlow objects support such a thing.
To recapitulate: Currently the standard [list split 2] would send "0 1" to the first outlet and "2 3 4" to the second. Should a fictional [list split -2] send "3 4" to the first or to the second outlet?
There is no precedent of something sufficiently like [list split] in Ruby, maybe Array#slice! would be the closest, which has in input a list and a cut-point just like yours, but also an optional length, defaulting to 1. Then it returns the specified portion of the list, and deletes that very same portion from the original list. For example:
a = [0 1 2 3 4] p a.slice!(2,2) # shows [2,3] p a # shows [0,1,4]
I don't know which of those two outputs should be the main one, but it should mirror a subsequent "unsplit" or "unslice" so that e.g.:
[list slice 2 2] | | [list unslice 2 2]
is a no-op (rebuilds exactly the same list), if the list is long enough and if the starting position is nonnegative.
(Note: I tend to prefer sendign "3 4" to the first outlet, as it's technically easier,
I don't know. What's technically easier about it?
Mathieu Bouchard - tél:+1.514.383.3801 - http://artengine.ca/matju Freelance Digital Arts Engineer, Montréal QC Canada
Hallo, Mathieu Bouchard hat gesagt: // Mathieu Bouchard wrote:
I don't know which of those two outputs should be the main one, but it should mirror a subsequent "unsplit" or "unslice" so that e.g.:
[list slice 2 2] | | [list unslice 2 2]
This no-op in Pd would be done as:
[list split] | | [list]
To keep this working using neg. indices would also require the tail being at the second outlet.
(Note: I tend to prefer sendign "3 4" to the first outlet, as it's technically easier,
I don't know. What's technically easier about it?
Actually it's no big deal: To keep the order of execution right to left, I just need to use an additional trigger and a [list] for intermediate storing.
Thanks to yours and IOhannes comments I see a bit clearer now and I decided to use the niagara way of splitting at negative indices.
I now did it that way. The abstraction is called [list-splat] (advanced list split) and is in SF-CVS or GOTO10-SVN at: http://royalrabbit.goto10.org/svn/goto10/pd-patches/fbar/list-abs/
It requires [list-rev] which has a little bug fixed.
Some more new [list]-abs: list-sieve, list-idx, list-equalize, list-normalize and, finally, list-abs. ;)
Frank Barknecht _ ______footils.org_ __goto10.org__