Contents
Sum the items in the given vector input.
input
vec<int, 5> x = {5, 0, 2, 1, 0}; int y = sum(x); // Returns 8
Find the maximum element in the given vector input.
vec<int, 5> x = {5, 0, 2, 1, 0}; int y = max(x); // Returns 5
Find the minimum element in the given vector input.
vec<int, 5> x = {5, 0, 2, 1, 0}; int y = min(x); // Returns 0
Multiply the items in the given vector input.
vec<int, 5> x = {5, 0, 2, 1, 0}; int y = product(x); // Returns 5*0*2*1*0 = 0
Check if all elements in the given vector input are non-zero. An element v is considered non-zero if bool(v)==true.
v
bool(v)==true
Check if any element in the given vector input is non-zero. An element v is considered non-zero if bool(v)==true.
Count the number of non-zero items in the given vector input. An element v is considered non-zero if bool(v)==true.
vec<int, 5> x = {5, 0, 2, 1, 0}; int y = count(x); // Returns 3 (5, 2, 1 are non-zero)