Results for “first lines”
Small, practical examples. Search by task or narrow things down below.
Find the first matching array item
TypeScript: find returns undefined when no item satisfies the predicate.
TypeScript✓ Tested
Find the first matching stream value
Java: Use findFirst and an explicit default for an empty result.
Java✓ Tested
Find the first matching value
Find the first matching value in a complete Rust program using the standard library.
Rust✓ Tested
Find the first matching value with a fallback
Python: Pass a generator and default to next to avoid building an intermediate list.
Python✓ Tested
Find the first occurrence of a character
C: strchr returns a pointer into the input or NULL if the character is absent.
C✓ Tested
Find the first value satisfying a condition
C++: Compare the returned iterator with end before dereferencing it.
C++✓ Tested
Join lines from two files side by side
Linux Commands: Use paste to pair lines by position with a chosen separator.
Linux Commands✓ Tested
Measure a node after the first render
Measure a node after the first render with a standalone Angular component and explicit browser behavior.
Angular✓ Tested
Print a first terminal message
Linux Commands: Print a first terminal message using GNU/Linux commands in an empty practice directory.
Linux Commands✓ Tested
Print a selected range of lines
Linux Commands: Use sed -n with a line address to suppress other output.
Linux Commands✓ Tested
Print the final lines of a file
Linux Commands: Use tail -n for a fixed-size suffix of a log.
Linux Commands✓ Tested
Process a first-in first-out queue
C++: Queue exposes its front item separately from the operation that removes it.
C++✓ Tested