Results for “Slices & collections”
Small, practical examples. Search by task or narrow things down below.
Remove duplicate values with a Set
Keep the first occurrence order while deduplicating.
Set✓ Tested
Remove duplicates from a list
Remove repeated hashable values while preserving the order in which they first appeared.
list✓ Tested
Remove odd values
Use the erase-remove idiom to filter a C++ vector in place.
C++✓ Tested
Select object properties
Create a smaller object with only the fields you need.
Select-Object✓ Tested
Sort a list
Sort a mutable Java list in natural ascending order.
Java✓ Tested
Sort a vector
Sort C++ integer values in ascending order.
C++✓ Tested
Sort and deduplicate values
Produce an ordered list without duplicates.
Sort-Object✓ Tested
Sort and deduplicate values
Sort a C++ vector and erase adjacent duplicates.
C++✓ Tested
Sort dictionaries by a value
Sort a list of dictionaries by a numeric field, leaving the original list unchanged.
sort✓ Tested
Sort values with LINQ
Create an ascending sequence from C# integer values.
C#✓ Tested
Sum a collection
Calculate a total with Measure-Object.
Measure-Object✓ Tested
Sum typed values with reduce
Accumulate numeric array elements.
reduce✓ Tested