def _compare_array_to_value(array, val):
    """
    Return i such that array[i] == val.

    If val not found return -1
    """
    for index, elem in enumerate(array):
        if elem == val:
            return index
    return -1