Results for “Array operations”
Small, practical examples. Search by task or narrow things down below.
Separate a first item from the remaining items
JavaScript: Array destructuring and a rest element produce named pieces of a sequence.
JavaScript✓ Tested
Separate a first item from the remaining items
TypeScript: Array destructuring and a rest element produce named pieces of a sequence.
TypeScript✓ Tested
Set owner-only read and write permissions
C++: Replace ordinary permission bits with the requested owner permissions.
C++✓ Tested
Sort only the smallest requested prefix
C++: partial_sort orders the selected prefix without guaranteeing the order of the remainder.
C++✓ Tested
Sort records by two fields
C++: Tuple comparison implements lexicographic ordering across several keys.
C++✓ Tested
Sort timestamp strings by their parsed instants
JavaScript: Compare epoch values explicitly when date strings may contain different offsets.
JavaScript✓ Tested
Sort timestamp strings by their parsed instants
TypeScript: Compare epoch values explicitly when date strings may contain different offsets.
TypeScript✓ 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 the decimal digits of an unsigned integer
C: Repeated division and remainder extract digits without converting to text.
C✓ Tested
Sum typed values with reduce
Accumulate numeric array elements.
reduce✓ Tested
Take an immutable list snapshot
Java: List.copyOf protects the snapshot from later changes to the source list.
Java✓ Tested