// =========================================================================== // Copyright 2018 Autodesk, Inc. All rights reserved. // // Use of this software is subject to the terms of the Autodesk license // agreement provided at the time of installation or download, or which // otherwise accompanies this software in either electronic or hard copy form. // =========================================================================== // // // // // int[] intArrayRemove(int[] $item, int[] $list) // // // Remove the int items in the first int array from the // second int array. A new int array with the // items removed is returned. The second argument is left // unchanged. //

// Note that all occurrences of the given // int items will be removed from the int array, not // just the first occurrence. // // // int[] $items A list of int values to remove from the int array. // int[] $list The array to be acted upon. // // // int[] : Original list with all occurrences of the int items // removed. If none of the int items are in the int array then // the returned int array is identical to the argument int array. // // // int $list[] = { 1, 2, 3, 4, 5, 6, 7, 8 }; // int $items[] = { 1, 3, 5, 7 }; // int $diff[] = intArrayRemove($items, $list); // // Result : { 2, 4, 6, 8 } // // // // global proc int [] intArrayRemove( int $items[], int $list[] ) { int $item, $listItem, $result[]; int $keep, $resultIndex = 0; for ($listItem in $list) { $keep = 1; for ($item in $items) { if ($item == $listItem) { $keep = 0; break; } } if ($keep) $result[$resultIndex++] = $listItem; } return $result; }