Results for “File operations & archives”
Small, practical examples. Search by task or narrow things down below.
Split an array into fixed-size batches
PowerShell: Bound the final index so the last batch can contain fewer elements.
PowerShell✓ Tested
Test whether an array contains a value
PowerShell: The contains operator compares complete items rather than matching substrings.
PowerShell✓ Tested
Add calendar days in UTC
JavaScript: Use UTC date setters to cross month boundaries without local daylight-saving effects.
JavaScript✓ Tested
Add calendar days in UTC
TypeScript: Use UTC date setters to cross month boundaries without local daylight-saving effects.
TypeScript✓ Tested
Append several items to an array
Bash Scripts: Array-plus-equals adds elements without losing spaces inside a quoted item.
Bash Scripts✓ Tested
Calculate a fixed-window moving average
C: For this small window, sum each complete group and skip incomplete prefixes.
C✓ Tested
Calculate a least common multiple using a GCD
C: Divide before multiplying to reduce the risk of intermediate overflow.
C✓ Tested
Calculate a small factorial iteratively
C: Multiply a bounded sequence using an unsigned accumulator.
C✓ Tested
Calculate an average without integer division truncation
C: Accumulate into double and divide by the nonzero number of readings.
C✓ Tested
Calculate the greatest common divisor
C: Euclid’s algorithm repeatedly replaces a pair with the divisor and remainder.
C✓ Tested
Change a path’s extension
Change a path’s extension in a complete Rust program using the standard library.
Rust✓ Tested
Check exact array membership
Bash Scripts: Compare each element literally instead of searching a concatenated string.
Bash Scripts✓ Tested