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

Dispatch a one-character serial command

Arduino / C: A switch provides explicit handling for accepted and unknown commands.

Arduino / C✓ Tested
PythonIteration & sequences

Find the first matching value with a fallback

Python: Pass a generator and default to next to avoid building an intermediate list.

Python✓ Tested
PythonIteration & sequences

Flatten one level of nested lists

Python: Use a nested comprehension when each input item is itself an iterable.

Python✓ Tested
PythonIteration & sequences

Generate combinations across two collections

Python: Use product for a Cartesian product; this differs from selecting combinations within one collection.

Python✓ Tested
Arduino / CSerial protocols

Handle incomplete serial input

Arduino / C: The returned byte count distinguishes a complete payload from a timed-out partial one.

Arduino / C✓ Tested
Arduino / CSerial protocols

Inspect a byte without consuming it

Arduino / C: peek leaves the next byte available for a later read.

Arduino / C✓ Tested
PythonIteration & sequences

Number items while iterating

Python: Use enumerate to attach a one-based position without maintaining a separate counter.

Python✓ Tested
PythonIteration & sequences

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
Arduino / CSerial protocols

Read a decimal number from serial input

Arduino / C: parseFloat parses a signed decimal value from the input stream.

Arduino / C✓ Tested
Arduino / CSerial protocols

Read a fixed-size serial payload

Arduino / C: readBytes returns the number of bytes actually received.

Arduino / C✓ Tested
Arduino / CSerial protocols

Read an integer from serial input

Arduino / C: parseInt skips leading nonnumeric characters and reads the next integer.

Arduino / C✓ Tested
Arduino / CSerial protocols

Read serial text up to a delimiter

Arduino / C: readBytesUntil excludes the delimiter and does not add a null terminator.

Arduino / C✓ Tested