c_src/hyper_carray.c
/*
 * Number of items with a 0 as value;
 */
Number of items with a 0 as value.
Number of items with a 0 as value .
static ERL_NIF_TERM zero_count(ErlNifEnv * env, int argc,
			       const ERL_NIF_TERM argv[])
{
	carray_ptr arr = NULL;
	HYPER_CARRAY_OR_BADARG(argv[0], arr);
	unsigned int nzeros = 0;
	unsigned int size = arr->size;
	for (int i = 0; i < size; ++i) {
		if (arr->items[i] == 0)
			++nzeros;
	}
	return enif_make_int(env, nzeros);
}
static ERL_NIF_TERM zero_count ( ErlNifEnv * env , int argc , const ERL_NIF_TERM argv [ ] ) { carray_ptr arr = NULL ; HYPER_CARRAY_OR_BADARG ( argv [ 0 ] , arr ) ; unsigned int nzeros = 0 ; unsigned int size = arr -> size ; for ( int i = 0 ; i < size ; ++ i ) { if ( arr -> items [ i ] == 0 ) ++ nzeros ; } return enif_make_int ( env , nzeros ) ; }
Number of items with a 0 as value;
Number of items with a 0 as value ;