Home

pnth

Pnth is a term used in theoretical computer science and mathematics to denote an operator that returns the n-th element of a sequence that satisfies a given predicate. The prefix p stands for a predicate or property, and nth indicates indexing within the filtered subsequence.

Formally, let S be a sequence (s1, s2, s3, ...), p(x) a boolean predicate, and n a positive

Equivalently, pnth(S, p, n) equals the n-th element of the filtered sequence S|p, where S|p = (si in

Applications of pnth appear in formal descriptions of selection under constraints, algorithmic design that involves constrained

Etymology and usage vary by author; pnth is not a standardized operator in mainstream mathematics or computer

integer.
pnth(S,
p,
n)
is
the
unique
element
sk
such
that
p(sk)
is
true
and
exactly
n−1
elements
among
s1,
...,
sk−1
satisfy
p.
If
there
are
fewer
than
n
elements
in
S
satisfying
p,
pnth
is
undefined
or
returns
a
designated
sentinel
value.
S
:
p(si)).
In
programming,
pnth
can
be
implemented
by
filtering
then
indexing,
or
by
a
streaming
algorithm
that
counts
until
reaching
n.
The
definition
is
independent
of
the
underlying
data
structure
as
long
as
the
sequence
order
is
preserved.
sampling,
and
the
study
of
order
statistics
within
filtered
data.
It
is
also
used
in
discussions
of
lazy
evaluation
and
query
languages
where
a
predicate
defines
a
restricted
domain
from
which
the
n-th
element
is
retrieved.
science.
When
used,
it
is
typically
clarified
by
specifying
the
exact
predicate
and
the
indexing
convention
to
avoid
ambiguity.
See
also
nth_element,
filter,
and
sequence.