// =========================================================================== // 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 intArrayCount(int $item, int[] $list) // // // Return the number of times the int in $item // occurs in the int array $list. // Zero is returned if the int is not in the list. // // // int $item The int item to search for in the int array. // int[] $list A list of int values. // // // int : The number of occurrences of the int item in the int array. // // // int $list[] = { 1, 2, 3, 2, 2 }; // // Result: item1 item2 item1 // // int $count = intArrayCount( 1, $list ); // // Result: 1 // // $count = intArrayCount( 2, $list ); // // Result: 3 // // $count = intArrayCount( 4, $list ); // // Result: 0 // // // // global proc int intArrayCount(int $item, int $list[]) { int $result = 0; int $listItem; for ($listItem in $list) { if ($item == $listItem) $result++; } return $result; }