Results for “File operations & integrity”
Small, practical examples. Search by task or narrow things down below.
Read the last array element
PowerShell: A negative array index counts backward from the end.
PowerShell✓ Tested
Reverse a copy while preserving the source
PowerShell: Clone the array before using Array.Reverse because Reverse mutates its argument.
PowerShell✓ Tested
Select elements by an index range
PowerShell: An index range selects the requested array positions in order.
PowerShell✓ Tested
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