OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: Doolittle on 04 Oct 2005, 07:26:53
-
I was wondering..is this the best way to get the result of values which appear in each array but not both???
a = [1, 2, 3, 4]
b = [1, 2, 3, 5]
c = (a - b) + (b - a)
..means c = [4, 5]
How to do this in OFP scripting? Just like that, right...but is there an easier way?
Doolittle
-
Hmmm.
I'm going to chance a 'yes, that's the best way' and a 'no, there is no better way', based on the fact that there are no specialised commands to do things like that to arrays, in the comref.
If you can find an algorithm to do what you want, then you're sorted anyhow :)
-
{If (_x In _array1) Then {_array1 = _array1 - [_x]; _array2 = _array2 - [_x]}} ForEach _array2
_resultarray = _array1 + _array2In English:
If an element in _array2 is in _array1 then subtract that element from both.
Add the leftovers together.
That's as slick as I can get it...
-
...which is not the easy way to do it
stick to your original code doolittle, thats the best
-
Isn't there function for this?
--Ben
-
i believe so but it isn't really necessary