Results for “Array transformations”
Small, practical examples. Search by task or narrow things down below.
Parse only valid integers
Parse only valid integers in a complete Rust program using the standard library.
Rust✓ Tested
Partition a collection by a predicate
Java: Use partitioningBy to retain both matching and nonmatching values.
Java✓ Tested
Partition values into two collections
Partition values into two collections in a complete Rust program using the standard library.
Rust✓ Tested
Read values until a condition changes
Read values until a condition changes in a complete Rust program using the standard library.
Rust✓ Tested
Reject insertion when a fixed queue is full
Arduino / C: Track a count separately from circular read and write positions.
Arduino / C✓ Tested
Remove duplicate records by a selected key
C#: DistinctBy keeps the first record for each key in encounter order.
C#✓ Tested
Return a collection as one pipeline object
PowerShell: The unary comma prevents the returned array from being enumerated at this boundary.
PowerShell✓ Tested
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