Iterating if statements in a coll

lennox's icon

Time for another dumb question from yours truly…

is it possible to apply an if/then/else iteratively on each index in a coll or any array? For example, if for each index, col 4 is a value other than 0, then the corresponding col7 value is adjusted by the difference in col 4

Like… (col 4= 2, then col 7= -2)

Bonus dumbass question: what if one wants to operate on a “range” of indicies? Say, I only want to apply this function to a range of index 13-63 or whatever?

love you cycling74 forum xoxo

Roman Thilenius's icon

for going through all indexes:
coll has a dump command. or use uzi.

for actions across indexes:
write down in a comment object what you want it to do in plain english.
then build what you wrote step by step around your coll, until it does what you want.
later make all the stuff except the coll an abstraction patch and give it a descriptive name.

if col 4 !=0 then col 7== col 4 * -1 should be done best using zl slice, but you could also write the list into zl nth and get the element to work on from there. probably the preferred method if you want to extract more than one element.

bonus dumbass: where "next" or "bang" do not work, i would probably use
uzi 1000
split 13 63
coll

to get a subset.

Source Audio's icon

there is also nsub message...

but as first, to treat 7th item in a list

it must exist.

what if index nn is shorter ?

anyway if all indexes have at least 7 items

then you could do something like this:

Max Patch
Copy patch and select New From Clipboard in Max.

recalling only specific range of indexes is easy to do.

try uzi or line etc