Home

occurrencesifC

occurrencesIfC is a conceptual function used in programming and formal discussions to identify or count occurrences in a collection that satisfy a given predicate C. The term is often used in pseudocode or language-agnostic explanations to illustrate predicate-based selection and counting.

Definition and variants: Given a sequence S = [s1, s2, ..., sn] and a predicate C(x) that returns

- a list of indices i where C(si) is true,

- a list of elements si that satisfy C,

- or just the count of elements that satisfy C, i.e., |{ i : C(si) is true }|.

Some descriptions differentiate occurrencesIfC (indices), elementsIfC (values), and countIfC (a number), with exact naming varying by

Implementation notes: In functional languages, you would typically filter elements or map to indices. In imperative

Example (pseudo):

function occurrencesIfC(sequence, C):

result = []

for i from 1 to length(sequence):

if C(sequence[i]):

result.append(i)

return result

Applications: predicate-based filtering, data analysis, text processing, event streams, and any scenario that requires locating elements

See also: count, filter, findAll, predicate, sequence processing.

true
or
false,
occurrencesIfC
can
return
different
results
depending
on
the
goal.
Common
variants
include:
language
or
library.
languages,
a
single
pass
can
accumulate
either
indices,
elements,
or
a
running
count.
The
choice
affects
memory
usage
and
performance:
counting
may
be
done
in
one
pass
with
O(1)
extra
space,
while
collecting
requires
additional
storage.
that
meet
a
condition.