Results for “number”
Small, practical examples. Search by task or narrow things down below.
Replace text using captured regex groups
C++: Numbered replacement groups can rearrange a known two-part name.
C++✓ Tested
Search a sorted vector
Use binary_search after ensuring C++ values are sorted.
C++✓ Tested
Search for text in a file
Find matching lines with their line numbers, ignoring letter case and treating the pattern as literal text.
grep✓ Tested
Select the top row in each group with a tie-breaker
SQL: Filter an outer query on ROW_NUMBER because window functions are not evaluated in WHERE.
SQL✓ Tested
Select the top row in each group with a tie-breaker
SQL Server: Filter an outer query on ROW_NUMBER because window functions are not evaluated in WHERE.
SQL Server✓ Tested
Select the top row in each group with a tie-breaker
Postgres: Filter an outer query on ROW_NUMBER because window functions are not evaluated in WHERE.
Postgres✓ Tested
Select the top row in each group with a tie-breaker
SQLite: Filter an outer query on ROW_NUMBER because window functions are not evaluated in WHERE.
SQLite✓ Tested
Set and test bit flags
Use unsigned masks to combine and test C flags.
C✓ Tested
Sum a range of integers
Use an arithmetic loop without launching external processes.
arithmetic✓ Tested
Sum integer values
Reduce a Java integer stream to its sum.
Java✓ Tested
Sum values per category
Calculate a grouped total.
SUM✓ Tested
Sum vector values
Use std::accumulate with a wide initial value.
C++✓ Tested