arrayIntersect: Difference between revisions
Jump to navigation
Jump to search
Lou Montana (talk | contribs) m (Text replacement - "\|x([0-9])= *<code>([^<]*)<\/code>" to "|x$1= <sqf>$2</sqf>") |
Lou Montana (talk | contribs) m (Some wiki formatting) |
||
Line 16: | Line 16: | ||
|r1= [[Array]] | |r1= [[Array]] | ||
|x1= <sqf>_arr1 = [1,2,3,4,5,2,3,4]; | |x1= <sqf> | ||
_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]</sqf> | hint str (_arr1 arrayIntersect _arr2); // [4,5,1,2,3] | ||
</sqf> | |||
|x2= <sqf>_arr = [1,2,3,1,2,3,1,2,3,4,5]; | |x2= <sqf> | ||
hint str (_arr arrayIntersect _arr); // [1,2,3,4,5]</sqf> | _arr = [1,2,3,1,2,3,1,2,3,4,5]; | ||
hint str (_arr arrayIntersect _arr); // [1,2,3,4,5] | |||
</sqf> | |||
|x3= Remove [[nil]]s: | |x3= Remove [[nil]]s: | ||
< | <sqf>hint str ([1,2,nil,3] arrayIntersect [1,2,nil,3]); // [1,2,3]</sqf> | ||
|x4= Also works with array elements which are [[isEqualTo|equal]]: | |x4= Also works with array elements which are [[isEqualTo|equal]]: | ||
< | <sqf>hint str ([[1],[2],[3]] arrayIntersect [[2],[3],[4]]); // [[2],[3]]</sqf> | ||
|x5= This command is case sensitive: | |x5= This command is case-sensitive: | ||
< | <sqf> | ||
["cAse"] arrayIntersect ["casE"]; // [] | ["cAse"] arrayIntersect ["cAse"]; // ["cAse"] | ||
["cAse"] arrayIntersect ["casE"]; // [] | |||
</sqf> | |||
|seealso= [[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]] | |seealso= [[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]] | ||
}} | }} |
Revision as of 19:57, 13 May 2022
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
- Syntax:
- array1 arrayIntersect array2
- Parameters:
- array1: Array
- array2: Array
- Return Value:
- Array
Examples
- Example 1:
- Example 2:
- Example 3:
- Remove nils:
- Example 4:
- Also works with array elements which are equal:
- Example 5:
- This command is case-sensitive:
["cAse"] arrayIntersect ["cAse"]; // ["cAse"] ["cAse"] arrayIntersect ["casE"]; // []
Additional Information
- See also:
- 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
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