Halstead Distinct Operands (n2) is one of the source-code metrics Understand computes across 17+ languages — browse them in the GUI, export and track them, or script them with the Python API.
Halstead Distinct Operands (n2)
API ID: HalsteadDistinctOperandsLanguages: Any
Targets: Files, Functions
Halstead Distinct Operands (n2) counts unique operands (identifiers and literals)
int
sample( // + 1 sample
)
{
int x // + 1 x
=
strlen( // + 1 strlen
"abc" // + 1 "abc"
);
return x // x already counted
*
2; // + 1 2
} // = 5