FIND YOUR NEXT FEW LINES

Results for “Promises & iteration protocols”

Small, practical examples. Search by task or narrow things down below.

57 snippets foundClear filters
Arduino / CSerial protocols

Search the stream for a message marker

Arduino / C: find consumes input through a matching marker or until timeout.

Arduino / C✓ Tested
PythonIteration & sequences

Separate records into two lists

Python: Build two explicit partitions so callers can use both matching and rejected values.

Python✓ Tested
PythonIteration & sequences

Split a list into fixed-size batches

Python: Slice a sequence at regular offsets; the final batch can be smaller.

Python✓ Tested
PythonIteration & sequences

Take a limited number of iterator values

Python: Use islice to consume only the requested prefix of a potentially unbounded iterator.

Python✓ Tested
Arduino / CSerial protocols

Validate a complete numeric serial command

Arduino / C: Check for digits, an end pointer, and an application-specific range.

Arduino / C✓ Tested
PythonIteration & sequences

Visit adjacent pairs

Python: Use itertools.pairwise to process neighboring items without indexing.

Python✓ Tested
TypeScriptUtilities & async

Await several independent results

Preserve input order while awaiting multiple promises.

Promise.all✓ Tested
CSmall algorithms & bit operations

Count set bits in an unsigned integer

C: Clearing the lowest set bit on each iteration counts only one iteration per set bit.

C✓ Tested
JavaScriptText handling & Unicode

Count Unicode code points in a string

JavaScript: String iteration combines surrogate pairs, unlike the UTF-16 length property.

JavaScript✓ Tested
TypeScriptText handling & Unicode

Count Unicode code points in a string

TypeScript: String iteration combines surrogate pairs, unlike the UTF-16 length property.

TypeScript✓ Tested
C++Filesystem operations

List regular files recursively in sorted order

C++: Collect relative paths before sorting because directory iteration order is unspecified.

C++✓ Tested
JavaQueues & collection operations

Preserve map insertion order

Java: Use LinkedHashMap when iteration should follow the order keys were first added.

Java✓ Tested