arrayIntersect: Difference between revisions
Jump to navigation
Jump to search
Lou Montana (talk | contribs) m (Text replacement - "_{10,} " to "") |
Lou Montana (talk | contribs) m (Text replacement - " *\| *([Cc]omments|COMMENTS|Game|[Gg]ame [Nn]ame|Game [Vv]ersion|Game Version \(number surrounded by NO SPACES\)|Multiplayer Arguments \("local" or "global"\)|Multiplayer Effects \("local" or "global"\)|Multiplayer Execution \("serv...) |
||
Line 1: | Line 1: | ||
{{Command | {{Command | ||
| arma3 | | arma3 | ||
|1.48 | |1.48 | ||
|gr1= Arrays | |gr1= Arrays | ||
| Intersects array1 with array2 returning array of unique common elements. Additionally, using the same array for array1 and array2 will simply return array of unique elements. Intersects only 1st dimension of an array. | | Intersects array1 with array2 returning array of unique common elements. Additionally, using the same array for array1 and array2 will simply return array of unique elements. Intersects only 1st dimension of an array. | ||
| array1 '''arrayIntersect''' array2 | | array1 '''arrayIntersect''' array2 | ||
|p1= array1: [[Array]] | |p1= array1: [[Array]] | ||
|p2= array2: [[Array]] | |p2= array2: [[Array]] | ||
| [[Array]] | | [[Array]] | ||
|x1= <code>_arr1 = [1,2,3,4,5,2,3,4]; | |x1= <code>_arr1 = [1,2,3,4,5,2,3,4]; | ||
_arr2 = [4,5,6,1,2,3,5,6]; | _arr2 = [4,5,6,1,2,3,5,6]; | ||
[[hint]] [[str]] (_arr1 [[arrayIntersect]] _arr2); // [4,5,1,2,3]</code> | [[hint]] [[str]] (_arr1 [[arrayIntersect]] _arr2); // [4,5,1,2,3]</code> | ||
|x2= <code>_arr = [1,2,3,1,2,3,1,2,3,4,5]; | |x2= <code>_arr = [1,2,3,1,2,3,1,2,3,4,5]; | ||
[[hint]] [[str]] (_arr [[arrayIntersect]] _arr); // [1,2,3,4,5]</code> | [[hint]] [[str]] (_arr [[arrayIntersect]] _arr); // [1,2,3,4,5]</code> | ||
|x3= Remove [[nil]]s:<code> [[hint]] [[str]] ([1,2,[[nil]],3] [[arrayIntersect]] [1,2,[[nil]],3]); // [1,2,3]</code> | |x3= Remove [[nil]]s:<code> [[hint]] [[str]] ([1,2,[[nil]],3] [[arrayIntersect]] [1,2,[[nil]],3]); // [1,2,3]</code> | ||
|x4= Also works with array elements which are [[isEqualTo|equal]]:<code> [[hint]] [[str]] ([[1],[2],[3]] [[arrayIntersect]] [[2],[3],[4]]); // [[2],[3]]</code> | |x4= Also works with array elements which are [[isEqualTo|equal]]:<code> [[hint]] [[str]] ([[1],[2],[3]] [[arrayIntersect]] [[2],[3],[4]]); // [[2],[3]]</code> | ||
|x5= This command is case sensitive:<code>["cAse"] [[arrayIntersect]] ["cAse"];{{cc|["cAse"]|true}} | |x5= This command is case sensitive:<code>["cAse"] [[arrayIntersect]] ["cAse"];{{cc|["cAse"]|true}} | ||
["cAse"] [[arrayIntersect]] ["casE"];{{cc|[]|true}}</code> | ["cAse"] [[arrayIntersect]] ["casE"];{{cc|[]|true}}</code> | ||
| [[append]], [[set]], [[pushBack]], [[pushBackUnique]], [[apply]], [[select]], [[resize]], [[reverse]], [[count]], [[find]], [[in]], [[forEach]], [[deleteAt]], [[deleteRange]], [[sort]], [[param]], [[params]], [[toArray]], [[toString]], [[splitString]], [[joinString]], [[BIS_fnc_arrayPushStack]], [[BIS_fnc_arrayPush]] | | [[append]], [[set]], [[pushBack]], [[pushBackUnique]], [[apply]], [[select]], [[resize]], [[reverse]], [[count]], [[find]], [[in]], [[forEach]], [[deleteAt]], [[deleteRange]], [[sort]], [[param]], [[params]], [[toArray]], [[toString]], [[splitString]], [[joinString]], [[BIS_fnc_arrayPushStack]], [[BIS_fnc_arrayPush]] | ||
}} | }} | ||
{{GameCategory|arma3|New Scripting Commands}} | {{GameCategory|arma3|New Scripting Commands}} | ||
{{GameCategory|arma3|Scripting Commands}} | {{GameCategory|arma3|Scripting Commands}} |
Revision as of 00:01, 18 January 2021
Description
- Description:
- Intersects array1 with array2 returning array of unique common elements. Additionally, using the same array for array1 and array2 will simply return array of unique elements. Intersects only 1st dimension of an array.
- Groups:
- Arrays
Syntax
Examples
- Example 1:
_arr1 = [1,2,3,4,5,2,3,4]; _arr2 = [4,5,6,1,2,3,5,6]; hint str (_arr1 arrayIntersect _arr2); // [4,5,1,2,3]
- Example 2:
_arr = [1,2,3,1,2,3,1,2,3,4,5]; hint str (_arr arrayIntersect _arr); // [1,2,3,4,5]
- Example 3:
- Remove nils:
hint str ([1,2,nil,3] arrayIntersect [1,2,nil,3]); // [1,2,3]
- Example 4:
- Also works with array elements which are equal:
hint str ([[1],[2],[3]] arrayIntersect [[2],[3],[4]]); // [[2],[3]]
- Example 5:
- This command is case sensitive:
["cAse"] arrayIntersect ["cAse"];// ["cAse"] ["cAse"] arrayIntersect ["casE"];// []
Additional Information
- See also:
- appendsetpushBackpushBackUniqueapplyselectresizereversecountfindinforEachdeleteAtdeleteRangesortparamparamstoArraytoStringsplitStringjoinStringBIS_fnc_arrayPushStackBIS_fnc_arrayPush
Notes
-
Report bugs on the Feedback Tracker and/or discuss them on the Arma Discord or on the Forums.
Only post proven facts here! Add Note