Results for “Slices & collections”
Small, practical examples. Search by task or narrow things down below.
Sort a vector in ascending order
Sort a vector in ascending order in a complete Rust program using the standard library.
Rust✓ Tested
Sort and remove repeated values
Sort and remove repeated values in a complete Rust program using the standard library.
Rust✓ Tested
Split a slice into two parts
Split a slice into two parts in a complete Rust program using the standard library.
Rust✓ Tested
Transform a collection into a plain array
jQuery: map followed by get returns ordinary JavaScript values.
jQuery✓ Tested
Use a last-in first-out stack
C#: Stack is useful for reversible traversal and other nested operations.
C#✓ Tested
Use case-insensitive dictionary keys
C#: Choose an ordinal comparer when case-insensitive keys represent identifiers.
C#✓ Tested
Count items by group
Group repeated values and report each count.
Group-Object✓ Tested
Count occurrences in a list
Count how often each value appears using Counter from the standard library.
count✓ Tested
Count word frequencies
Use Map.merge to count repeated words in Java.
Java✓ Tested
Count word frequencies
Accumulate word counts in an ordered C++ map.
C++✓ Tested
Count words using a Map
Update a keyed counter without losing its value type.
Map✓ Tested
Count words with GroupBy
Group repeated C# words and print ordered counts.
C#✓ Tested