Results for “seq”
Small, practical examples. Search by task or narrow things down below.
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 value satisfying a condition
C++: Compare the returned iterator with end before dereferencing it.
C++✓ Tested
Flatten one level of nested lists
Python: Use a nested comprehension when each input item is itself an iterable.
Python✓ Tested
Generate combinations across two collections
Python: Use product for a Cartesian product; this differs from selecting combinations within one collection.
Python✓ Tested
Generate numbers with a recursive CTE
Build a bounded sequence using SQL recursion.
recursive CTE✓ Tested
Number items while iterating
Python: Use enumerate to attach a one-based position without maintaining a separate counter.
Python✓ Tested
Pair corresponding list items
Python: Zip two equally sized sequences into pairs; strict mode rejects mismatched lengths on Python 3.10 or later.
Python✓ Tested
Run dependent async steps in order
JavaScript: Await one result before using it as the input of the next calculation.
JavaScript✓ Tested
Run dependent async steps in order
TypeScript: Await one result before using it as the input of the next calculation.
TypeScript✓ Tested
Separate records into two lists
Python: Build two explicit partitions so callers can use both matching and rejected values.
Python✓ Tested
Split a list into fixed-size batches
Python: Slice a sequence at regular offsets; the final batch can be smaller.
Python✓ Tested
Take a limited number of iterator values
Python: Use islice to consume only the requested prefix of a potentially unbounded iterator.
Python✓ Tested