FIND YOUR NEXT FEW LINES

Results for “collect”

Small, practical examples. Search by task or narrow things down below.

164 snippets foundClear filters
C#Collections

Count words with GroupBy

Group repeated C# words and print ordered counts.

C#✓ Tested
PythonCollections

Filter a list with a condition

Build a new list containing only the values that satisfy a condition using a list comprehension.

list✓ Tested
TypeScriptCollections & records

Filter and transform an array

Keep active objects and extract their names.

filter✓ Tested
C#Collections

Filter even numbers

Use LINQ Where to keep even C# values.

C#✓ Tested
JavaCollections

Filter even numbers

Use a Java stream to collect only even values.

Java✓ Tested
PowerShellCollections & objects

Filter items in a pipeline

Keep numbers that meet a condition.

Where-Object✓ Tested
PowerShellStrings & literal text

Join several strings with a separator

PowerShell: The join operator returns one string from an input collection.

PowerShell✓ Tested
JavaStream transformations

Join transformed stream values

Java: Use Collectors.joining after converting elements to strings.

Java✓ Tested
C++Filesystem operations

List regular files recursively in sorted order

C++: Collect relative paths before sorting because directory iteration order is unspecified.

C++✓ Tested
C#Collections

Look up a dictionary value

Use TryGetValue for a C# dictionary lookup with a fallback.

C#✓ Tested
C++Collections

Look up a map key

Use find to read a C++ map without inserting a missing key.

C++✓ Tested
PythonCollections

Merge two dictionaries

Combine two dictionaries into a new dictionary. When a key appears in both inputs, the value from the second dictionary wins.

dictionary✓ Tested