Jump to content
Sign in to follow this  
Kushluk

Searching/finding/subtracting arrays.

Recommended Posts

I have a single large array containing a large number of arrays which each contain three randomly generated strings.

_array = [ [ "A","B","C" ] , [ "D","E","F" ] , [ "G","H","I" ] , [...] , [...] ....];

I have one of those strings. _mystring will always be the third element.

_mystring = "F";

I now need to remove the array holding that string from the large array.

[ "D","E","F" ];

It should look like this afterwards:

_array = [ [ "A","B","C" ] , [ "G","H","I" ] ,  [...] , [...] ....];

I have investigated find and number other tutorials [1,2,3], however I am struggling with the searching and array subtraction :confused:

If anyone could assist me with completing my code segment, I would be highly appreciative:

_largeArray = [ [ "A","B","C" ] , [ "D","E","F" ] , [ "G","H","I" ] , [ "J","K","L" ] ];

_myString = "L";

// ........................
// Assistance needed to fill in the gaps here. The string _myString could be "C", "F", "I" or "L" in this case.
// ........................

_largeArray = [ [ "A","B","C" ] , [ "D","E","F" ] , [ "G","H","I" ] ];

Edited by Kushluk
typo

Share this post


Link to post
Share on other sites

Check out the functions viewer. There's quite a few BIS functions dealing with arrays that might help.

Share this post


Link to post
Share on other sites

_largeArray = [ [ "A","B","C" ] , [ "D","E","F" ] , [ "G","H","I" ] , [ "J","K","L" ] ];

_myString = "L";

{
if (_myString in _x) then {
	_largeArray set [_forEachIndex, -1];
};
}forEach _largeArray;

_laregArray = _largeArray - [-1];

Good thread to read about arrays

Edited by Larrow

Share this post


Link to post
Share on other sites

Thank you very much Larrow. That is very helpful.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×