List element replace

May 9, 2006 at 11:03pm

List element replace

I think I’m experiencing a brain freeze here…

Given a list (of varying size), I want to change one of the elements.

Linterp (from the Lobjects) allows me to grab an element, but how do I replace it?

I’m currently using funbuff, table, multislider, and coll, all of which work, but there must be a more efficient way….

#25884
May 9, 2006 at 11:11pm

substitute.

#76749
May 9, 2006 at 11:57pm

maybe with zl objects?

#76750
May 10, 2006 at 5:09am

I don’t think I was clear enough.

Given a list [3 5 4 8], I want to, for example, increment the 3rd element by one to get [3 5 5 8].

Isn’t there a way to do this without using a table?

#76751
May 10, 2006 at 5:22am

Lobjects Lobjects Lobjects
check out lpad and ladd

#76752
May 10, 2006 at 6:57am

That combination does the trick.

Thanks!

#76753
May 10, 2006 at 7:22am

or try my [replacelist]

/*j

#76754
May 11, 2006 at 9:04am

Arne Eigenfeldt wrote:
> Given a list [3 5 4 8], I want to, for example, increment the 3rd
> element by one to get [3 5 5 8].

completely different task than you explained in the first mail…

use a simple unpack, pack combo, a messagebox, or more universal
zl nth, (part of the zl help file copied in)

Stefan

#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#P comment 360 101 114 196617 nth , additional feature:;
#P newex 438 165 27 196617 t b l;
#P message 438 145 38 196617 $1 0.5;
#P number 438 125 38 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P message 474 190 25 196617 2 hi;
#P newex 424 234 65 196617 print nthless;
#P newex 372 234 45 196617 print nth;
#P button 358 190 15 0;
#P message 346 145 80 196617 5 6 7 8 9 10 11;
#P newex 392 206 42 196617 zl nth 3;
#B color 5;
#P window linecount 4;
#P comment 494 128 143 196617 extra argument to right inlet specifies
. nth element will be replaced with in right oulet list.;
#P window linecount 1;
#P message 239 239 50 196617 3 5 38 8;
#P newex 239 216 63 196617 prepend set;
#P number 239 118 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 239 144 83 196617 sprintf 3 5 %i 8;
#P message 171 239 50 196617 3 5 7 8;
#P message 53 239 50 196617 3 5 17 8;
#P newex 171 216 63 196617 prepend set;
#P newex 53 216 63 196617 prepend set;
#P number 171 118 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P message 171 144 50 196617 3 5 $1 8;
#P newex 65 168 13 196617 b;
#P number 105 168 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 53 189 88 196617 pack 1 2 3 4;
#P newex 53 145 88 196617 unpack 1 2 3 4;
#P message 53 122 50 196617 3 5 4 8;
#P connect 16 0 19 0;
#P connect 17 0 16 0;
#P connect 18 0 16 0;
#P connect 24 0 16 0;
#P connect 21 0 16 1;
#P connect 24 1 16 1;
#P connect 16 1 20 0;
#P connect 22 0 23 0;
#P connect 23 0 24 0;
#P connect 12 0 11 0;
#P connect 11 0 13 0;
#P connect 13 0 14 0;
#P connect 8 0 10 0;
#P connect 7 0 9 0;
#P connect 5 0 8 0;
#P connect 2 0 7 0;
#P connect 6 0 5 0;
#P connect 3 0 4 0;
#P connect 3 0 2 2;
#P connect 4 0 2 0;
#P connect 1 3 2 3;
#P connect 1 1 2 1;
#P connect 1 0 2 0;
#P connect 0 0 1 0;
#P window clipboard copycount 26;


Stefan Tiedje————x—-
–_____———–|———–
–(_|_ —-|—–|—–()—-
– _|_)—-|—–()———–
———-()—–www.ccmix.com

#76755

You must be logged in to reply to this topic.