BIS fnc consolidateArray: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - "\[\[Category\:Function Group\: Arrays(\|\{\{[a-zA-Z0-9_:]+\}\})?\]\]" to "")
m (Text replacement - "_{10,} " to "")
Line 1: Line 1:
{{Function|Comments=
{{Function|Comments=
____________________________________________________________________________________________


| arma3 |Game name=
| arma3 |Game name=
Line 7: Line 6:


|gr1= Arrays|GROUP1=
|gr1= Arrays|GROUP1=
____________________________________________________________________________________________


|Finds duplicities in the given array of anything and consolidates them into an array of sub-arrays |DESCRIPTION=
|Finds duplicities in the given array of anything and consolidates them into an array of sub-arrays |DESCRIPTION=
____________________________________________________________________________________________


| array call [[BIS_fnc_consolidateArray]] |SYNTAX=
| array call [[BIS_fnc_consolidateArray]] |SYNTAX=
Line 19: Line 16:
* value: [[Anything]] - consolidated element
* value: [[Anything]] - consolidated element
* count: [[Number]] - occurrence count|RETURNVALUE=
* count: [[Number]] - occurrence count|RETURNVALUE=
____________________________________________________________________________________________


|x1= <code>["apple","apple","pear","pear","apple"] [[call]] [[BIS_fnc_consolidateArray]]; // Return: [<nowiki/>["apple",3],["pear",2]]</code> |Example1=
|x1= <code>["apple","apple","pear","pear","apple"] [[call]] [[BIS_fnc_consolidateArray]]; // Return: [<nowiki/>["apple",3],["pear",2]]</code> |Example1=
Line 25: Line 21:
|x2= <code>["apple","apple",1,1,[[nil]],[[nil]]] [[call]] [[BIS_fnc_consolidateArray]]; // Return: [<nowiki/>["apple",2],[1,2],[any,2]]</code> |=  
|x2= <code>["apple","apple",1,1,[[nil]],[[nil]]] [[call]] [[BIS_fnc_consolidateArray]]; // Return: [<nowiki/>["apple",2],[1,2],[any,2]]</code> |=  
____________________________________________________________________________________________


| |SEEALSO=
| |SEEALSO=

Revision as of 23:33, 16 January 2021

Hover & click on the images for description

Description

Description:
Finds duplicities in the given array of anything and consolidates them into an array of sub-arrays
Execution:
call
Groups:
Arrays

Syntax

Syntax:
array call BIS_fnc_consolidateArray
Parameters:
array: Array - array of anything
Return Value:
Array - array of sub-arrays in format [[value, count],...], where:
  • value: Anything - consolidated element
  • count: Number - occurrence count

Examples

Example 1:
["apple","apple","pear","pear","apple"] call BIS_fnc_consolidateArray; // Return: [["apple",3],["pear",2]]
Example 2:
["apple","apple",1,1,nil,nil] call BIS_fnc_consolidateArray; // Return: [["apple",2],[1,2],[any,2]]

Additional Information

See also:
See also needed

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

Notes

Bottom Section