Gradually accumulate numbers in a list until they are all equal

halie's icon

Hello,

I have a math question. I have a list of floats (35-40 numbers in the list) and I want to gradually add a set number to each one until they are all the same. I know I can add a number to each element in a list with vexpr  but can't figure out how to do it as a continual accumulation. Further, Vexpr keeps truncating the decimal points of the floats.

Thanks for the help!

Rick's icon

Something like this. [vexpr (($f1

Roman Thilenius's icon

you could first find the average or median or where ever you want to go, then use + or slide to do the steps.

metamax's icon

I want to gradually add a set number to each one until they are all the same.

Does each list element need to add to exactly the same number via the same incremental value? If so, how are you deriving the number that will incrementally increase all of the list elements to the same value? If you were referencing integers I would be thinking in terms of a greatest common divisor, but you're talking about floats.

I know I can add a number to each element in a list with vexpr but can’t figure out how to do it as a continual accumulation.

If you use a message box to input your list, you can feed the output of vexpr to the right inlet of the input message box... and keep clicking or banging the message box to input the newly updated list.

Further, Vexpr keeps truncating the decimal points of the floats.

Be sure you are using $f1 changeable args, not $i1.

metamax's icon

I like Rick's approach. You can also use the minimum and clip objects so that your final output is a list of identical values.

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

halie's icon

Thanks so much--this solution works perfectly!