points by AdieuToLogic 1 hour ago | 0 comments
Why not use the C/C++ idiom of pointer math?
_Bool find_last (size_t count, int *haystack, int needle, size_t *where)
{
for (const int *pos = haystack + count; pos-- != haystack;) {
if (*pos == needle) {
*where = pos - haystack;
return 1;
}
}
return 0;
}
[–] i2talics 1 hour ago