Results for “Bulk changes & set operations”
Small, practical examples. Search by task or narrow things down below.
Find values missing from another collection
Python: Use a set difference to identify requested IDs absent from the available IDs.
Python✓ Tested
Find values shared by two collections
Python: Use set intersection and sort the result for deterministic display.
Python✓ Tested
Format whole seconds as hours minutes and seconds
JavaScript: Use integer divisions and remainders for a nonnegative duration.
JavaScript✓ Tested
Format whole seconds as hours minutes and seconds
TypeScript: Use integer divisions and remainders for a nonnegative duration.
TypeScript✓ Tested
Generate a bounded Fibonacci sequence
C: Keep only the two previous values instead of using exponential recursive calls.
C✓ Tested
Give related form fields a shared title
HTML: Learn how to give related form fields a shared title in a complete browser example.
HTML✓ Tested
Group records by a field
Python: Accumulate related values with defaultdict without checking whether each group exists.
Python✓ Tested
Group related form controls semantically
Group related form controls semantically with a small React component and explicit browser behavior.
React✓ Tested
Handle a failed file open through stream state
C++: An unopened input stream is not an empty successful file read.
C++✓ Tested
Hash a file without reading it all at once
Python: Feed fixed-size binary chunks into SHA-256 for files larger than memory.
Python✓ Tested
Initialize a map entry only when absent
Java: Use computeIfAbsent when creating a collection for a new key.
Java✓ Tested
Insert and retrieve a map value
Insert and retrieve a map value in a complete Rust program using the standard library.
Rust✓ Tested