davidoss 550 Posted April 30, 2016 Hi. I want to ask you fellows if there are any function or command that could format passed nested arrays to un-nested one? I have tried to write such thing but this iteration inside iteration breaking my brain. _weapons = [["CUP_arifle_L85A2_SUSAT_Laser","Throw","Put"],["CUP_arifle_L85A2_Holo_laser","CUP_hgun_Colt1911","Throw","Put","CUP_Vector21Nite"],["CUP_arifle_L85A2_Holo_laser","Throw","Put","Binocular"]]; _weapons call { _unnested = []; { _unnested pushBackUnique _x; } forEach {_this select _x} forEach _this; _unnested }; Need to get: ["CUP_arifle_L85A2_SUSAT_Laser","Throw","Put","CUP_arifle_L85A2_Holo_laser","CUP_hgun_Colt1911","CUP_Vector21Nite","Binocular"]; Please help Share this post Link to post Share on other sites
Grumpy Old Man 3540 Posted April 30, 2016 Not quite sure how you came to your weird forEach forEach syntax, but this should work: _unnest = { params ["_input"]; _output = []; { _nest = _x; { _output pushBackUnique _x; } foreach _nest; } foreach _input; _output }; Cheers Share this post Link to post Share on other sites
Greenfist 1863 Posted April 30, 2016 _weapons call { _unnested = []; { { _unnested pushBackUnique _x } foreach _x } forEach _this; _unnested }; damn. Beaten by the elderly fellow. 1 Share this post Link to post Share on other sites
davidoss 550 Posted April 30, 2016 Thank you. You are really a code beast. Share this post Link to post Share on other sites