quick addition of many numbers

Jay's icon

Greetings,

I'm looking to do some adding. For one, I'd like to be able to quickly add the numbers present in a list together. No [zl] mode that I know of does this. My list contains, for example, [1, 3, 4, 6, 7]. Upon inputting the list into this object, the sum (21) will be output.

Also, I'd like to have an object or abstraction that keeps a running total of the sum of all the numbers which are input into it.

These two are actually pretty similar. What's the best way of accomplishing this in 4.6?

Jay

LoneMonad aka don malone's icon
fairesigneaumachiniste's icon

I would say [iter] - [accum]

but bizarrely on my machine on both max 5 and 4.6, accum isn't accumulating.

Mac OS X 10.5.4
Max 5.0.3 and 4.6.3

Jay's icon

Thanks for the responses. I'm not familiar with [accum]. Sounds like I need to get familiar.

Jay

mrjester's icon

There is a zl mode. It's zl sum. I'm not sure if that mode exists under 4.6, however. Accum certainly will work, and you could easily use iter, trigger, and accum together to make an abstraction that did the same thing as zl sum.

Chris Muir's icon

On Sep 2, 2008, at 11:28 AM, Jer Welter wrote:

> There is a zl mode. It's zl sum. I'm not sure if that mode exists
> under 4.6, however.

It doesn't.

You could also use + with feedback:

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

Chris Muir
cbm@well.com    
http://www.xfade.com

kjg's icon

another option, providing the lists don't get longer than 9 items:

expr $i1+$i2+$i3+$i4+$i5+$i6+$i7+$i8+$i9

Emmanuel Jourdan's icon

On 2 sept. 08, at 21:49, Klaas-Jan Govaart wrote:

> another option, providing the lists don't get longer than 9 items:

another one: [mean] * [zl len] ;-)

ej

Peter Castine's icon

Send your list to lp.sigma.

It's that easy.

Lp.sigma is in the Litter Starter Pack. URI below.

Some folks have suggested that a name like "lp.add" or "lp.sum" might be more obvious, but I actually polled Litter Power users on this and the broad majority found sigma sufficiently obvious and/or more attractive. So there it is.

Best -- Peter

Peter Castine's icon

Quote: Emmanuel Jourdan wrote on Wed, 03 September 2008 00:23
----------------------------------------------------
> another one: [mean] * [zl len] ;-)
----------------------------------------------------

Cute, but does have potential precision problems with int/float conversion.

Never mind that it's a Rube Goldberg-like solution to a simple problem. (Heath Robinson for the Brits)