Logo

Programming-Idioms

This language bar is your friend. Select your favorite languages!

Idiom #191 Check if any value in a list is larger than a limit

Given a one-dimensional array a, check if any value is larger than x, and execute the procedure f if that is the case

unsigned i;
for (i = 0; i < sizeof(a) / sizeof(a[0]); ++i) {
	if (a[i] > x) {
		f();
		break;
	}
}

New implementation...
< >
tkoenig