Home

finalwhere

Finalwhere is a term used in some mathematical and computer science discussions to refer to the final location, index, state, or element in a finite set or process that satisfies a given condition. It is typically described as the rightmost or last position at which a predicate holds.

Formal notion and definition: Consider a finite sequence a1, a2, ..., an and a predicate P that can

Examples: Let the sequence be (2, 5, 3, 9) and P(x) be “x > 3.” The indices with

Variations and notes: In some contexts, finalwhere assumes a monotone predicate or a specific data structure,

See also: rightmost true, last occurrence, last index, end position.

be
evaluated
at
each
index
or
element.
The
finalwhere
of
P
in
the
sequence
is
defined
as
the
largest
i
in
{1,
...,
n}
such
that
P(ai)
is
true,
when
such
an
i
exists.
If
no
index
satisfies
P,
finalwhere
is
usually
left
undefined
or
noted
as
none
(depending
on
context).
Variants
may
use
0-based
indexing
or
define
the
result
as
a
special
sentinel
value.
P
true
are
i
=
2
and
i
=
4,
so
the
finalwhere
is
4.
If
P(x)
were
“x
<
0,”
the
finalwhere
would
be
undefined
for
this
sequence.
which
can
influence
how
it
is
computed
(for
instance,
via
binary
search
on
monotone
predicates).
The
term
remains
informal
and
is
not
part
of
a
standardized
terminology
set;
its
precise
meaning
can
vary
between
authors.