Results for “Array traversal & selection”
Small, practical examples. Search by task or narrow things down below.
Return the first item with a generic function
Preserve the element type while allowing empty arrays.
generics✓ Tested
Reverse a copy while preserving the original
JavaScript: Copy before reverse because reverse mutates the array it receives.
JavaScript✓ Tested
Reverse a copy while preserving the original
TypeScript: Copy before reverse because reverse mutates the array it receives.
TypeScript✓ Tested
Reverse a copy while preserving the source
PowerShell: Clone the array before using Array.Reverse because Reverse mutates its argument.
PowerShell✓ Tested
Select elements by an index range
PowerShell: An index range selects the requested array positions in order.
PowerShell✓ Tested
Sort preferred rows ahead of other rows
SQL: A CASE ordering key expresses business priority before a stable secondary sort.
SQL✓ Tested
Sort preferred rows ahead of other rows
SQL Server: A CASE ordering key expresses business priority before a stable secondary sort.
SQL Server✓ Tested
Sort preferred rows ahead of other rows
Postgres: A CASE ordering key expresses business priority before a stable secondary sort.
Postgres✓ Tested
Sort preferred rows ahead of other rows
SQLite: A CASE ordering key expresses business priority before a stable secondary sort.
SQLite✓ Tested
Store a variable-length payload after a structure header
C: A flexible array member lets one allocation hold metadata and trailing bytes.
C✓ Tested
Store samples in a fixed-size ring buffer
Arduino / C: The write position wraps while the storage size stays constant.
Arduino / C✓ Tested
Sum typed values with reduce
Accumulate numeric array elements.
reduce✓ Tested