actionscript 3 - Compare Two Arrays, Get Uncommon Values -
I have a common problem that is having trouble bothering me:
var OldValues: array = [4, 5, 6]; Var Newellus: Array = [3, 4, 6, 7];
- I want to get value from new values which are not in old prices - 3, 7
- I get those values from those old values
- One way to add both sets of values of the same kind would be good - 3, 5, 7
I only want to Can I think of a complex method using some nested loops that do nothing redundant? ? Thank you.
You need a bunch of loops, but you can customize them and fully nested Using a loop, a lookup object
var old valve: array = [4, 5, 6]; Var Newellus: Array = [3, 4, 6, 7]; Var oldNotInNew: array = new array (); Var newNotInOld: Array = new Array (); Var old makeup: object = new object (); Var i: int; For each one (in old values) {old lookup [i] = true; } For each (in new values) {if (oldLookup [i]) {Delete old lookup [i]; } And {newNotInOld.push (i); }} For (var k: string in old script) {oldNotInNew.push (parseInt (k)); } Trace ("Not old in old:" + old knot in new); Trace ("Not New in Old:" + New Not In Old);
Result:
Not new in old: 5
Not old in new: 3,7
Comments
Post a Comment