[PD] feature request for [list]

Chris McCormick chris at mccormick.cx
Thu Apr 20 03:26:24 CEST 2006


On Wed, Apr 19, 2006 at 01:02:14PM -0400, Mathieu Bouchard wrote:
> On Wed, 19 Apr 2006, Miller Puckette wrote:
> 
> > The negative index thing for "nth" sounds like a bad idea, out of
> > keeping with Pd's more usual style of limiting out-of-range values to
> > the end of the range in question.
> 
> Ok, so you want people to do it like this instead?
> 
>    |
>   [t l l]
>    |   |
>    |  [list length]
>    |   |
>    |  [- ] <--- feed me
>    |   |
>   [list nth]
>    |

You can do negative indicies of a list with a single modulus operator
tuned to the length of the list:

         list index to look up
           |
	   | [r mylist]
	   |  |
	   | [list length]
	   |  |
[r mylist] [mod]
  |        |
 [list split]
  |

Chris.

-------------------
chris at mccormick.cx
http://mccormick.cx




More information about the Pd-list mailing list