# Array roll up

## Recommended Posts

Hi All!

Does anybody know about ready function which can roll an array with grouping and summing values.

Example 2D array BEFORE:

Name Orders

John 25

Smith 30

John 10

Example 2D array AFTER:

Name Orders

John 35

Smith 30

I could write my own, but if somewhere is ready to function - what a shame to spend time.

Sorry, if this question is very simple. I'm beginning programmer.

And sorry for my english.

Thanks for for answers (if they will)

##### Share on other sites

I've never seen a UDF specifically for that (not saying there isnt one), but I'm sure there will be a combination of UDFs you could use to achieve it.

My personal thought are that it would take you longer to learn the ready functions and implement them, than it would to make your own custom function. And you would learn more writing your own.

Monkey's are, like, natures humans.

##### Share on other sites

I've never seen a UDF specifically for that (not saying there isnt one), but I'm sure there will be a combination of UDFs you could use to achieve it.

My personal thought are that it would take you longer to learn the ready functions and implement them, than it would to make your own custom function. And you would learn more writing your own.

Thank u!

##### Share on other sites

It makes life easier to process arrays in reverse order when you're likely to be doing deletions to the array.

Something like:

```#include <Array.au3>

_ArrayDisplay(\$array)

For \$x = UBound(\$array) - 1 to 1 Step -1
For \$y = \$x - 1 to 0 Step -1
If \$array[\$x][0] = \$array[\$y][0] Then
\$array[\$y][1] += \$array[\$x][1]
_ArrayDelete(\$array, \$x)
ExitLoop
EndIf
Next
Next

_ArrayDisplay(\$array)```
Edited by Spiff59
##### Share on other sites

It makes life easier to process arrays in reverse order when you're likely to be doing deletions to the array.

Thank u very much!

## Create an account

Register a new account

• ### Recently Browsing   0 members

×

• Wiki

• Back

• #### Beta

• Git
• FAQ
×
• Create New...