Results for “first lines”
Small, practical examples. Search by task or narrow things down below.
Build a minimum-priority queue
C++: Supply greater as the comparator because priority_queue defaults to the largest value first.
C++✓ Tested
Calculate a page count without an overflowing addition
C: Divide first and add one only when a nonzero remainder remains.
C✓ Tested
Calculate changes between successive readings
C++: adjacent_difference keeps the first value and then writes each difference from its predecessor.
C++✓ Tested
Calculate differences between adjacent readings
JavaScript: Slice off the first value and compare each remaining value with its predecessor.
JavaScript✓ Tested
Calculate differences between adjacent readings
TypeScript: Slice off the first value and compare each remaining value with its predecessor.
TypeScript✓ Tested
Check an upper integer bound before adding
C++: For these nonnegative values, compare against the maximum minus the addend first.
C++✓ Tested
Check whether every item matches
JavaScript: every stops at the first failed predicate and returns true for an empty array.
JavaScript✓ Tested
Check whether every item matches
TypeScript: every stops at the first failed predicate and returns true for an empty array.
TypeScript✓ Tested
Choose among several numeric ranges
Bash Scripts: An if-elif chain evaluates branches in order and executes the first match.
Bash Scripts✓ Tested
Collect a serial line in a fixed buffer
Read a short command without dynamic String allocation.
serial line✓ Tested
Commit multiple related changes together
SQL: The first transaction prepares the fixtures. The second commits both updates as one unit.
SQL✓ Tested
Commit multiple related changes together
SQL Server: The first transaction prepares the fixtures. The second commits both updates as one unit.
SQL Server✓ Tested