noknown Posted August 23, 2011 Posted August 23, 2011 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 Adams 20 John 10 Adams 30 Example 2D array AFTER: Name Orders John 35 Smith 30 Adams 50 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)
JohnOne Posted August 23, 2011 Posted August 23, 2011 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. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
noknown Posted August 23, 2011 Author Posted August 23, 2011 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!
Spiff59 Posted August 23, 2011 Posted August 23, 2011 (edited) 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> Global $array[6][2] = [["John",25],["Smith",30],["Adams",20],["John",10],["Adams",30],["John",5]] _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 August 23, 2011 by Spiff59
noknown Posted August 23, 2011 Author Posted August 23, 2011 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!
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now