Results for “library”
Small, practical examples. Search by task or narrow things down below.
Flatten one level of nested lists
Python: Use a nested comprehension when each input item is itself an iterable.
Python✓ Tested
Format a decimal number
Format a Java decimal with two digits and a fixed locale.
Java✓ Tested
Format a decimal value
Print two fractional digits with C printf.
C✓ Tested
Format a readable status message
Format a readable status message using a complete Go program with explicit sample inputs.
Go✓ Tested
Format a UTC timestamp
Format a UTC timestamp using a complete Go program with explicit sample inputs.
Go✓ Tested
Format an integer as padded hexadecimal
Format an integer as padded hexadecimal in a complete Rust program using the standard library.
Rust✓ Tested
Format decimal output
Use fixed and setprecision to print two C++ decimal places.
C++✓ Tested
Generate a half-open range of dates
Java: datesUntil includes the starting date and excludes the end date.
Java✓ Tested
Generate combinations across two collections
Python: Use product for a Cartesian product; this differs from selecting combinations within one collection.
Python✓ Tested
Group fields in a struct
Group fields in a struct using a complete Go program with explicit sample inputs.
Go✓ Tested
Group records by a field
Python: Accumulate related values with defaultdict without checking whether each group exists.
Python✓ Tested
Group strings by their length
Java: Choose a TreeMap supplier when group keys must have deterministic order.
Java✓ Tested