Results for “Function scope & composition”
Small, practical examples. Search by task or narrow things down below.
Choose an action with switch
Map a small command value to a result.
switch✓ Tested
Convert ASCII text to lowercase safely
C++: Cast each byte to unsigned char before using the cctype function.
C++✓ Tested
Convert ASCII text to lowercase safely
C: Cast to unsigned char before calling ctype functions on a possibly signed char.
C✓ Tested
Convert received ASCII letters to uppercase
Arduino / C: ctype functions should receive an unsigned character value.
Arduino / C✓ Tested
Create independent rows in a matrix
JavaScript: Use a mapping function to create each row instead of sharing one array with fill.
JavaScript✓ Tested
Create independent rows in a matrix
TypeScript: Use a mapping function to create each row instead of sharing one array with fill.
TypeScript✓ Tested
Delegate iteration to another iterable
JavaScript: yield-star forwards items from another iterable while retaining generator composition.
JavaScript✓ Tested
Delegate iteration to another iterable
TypeScript: yield-star forwards items from another iterable while retaining generator composition.
TypeScript✓ Tested
Describe an object with an interface
Require named fields on a reusable object shape.
interface✓ Tested
Discard incidental output from a setup command
PowerShell: Out-Null prevents setup objects from becoming part of a function or script’s useful result.
PowerShell✓ Tested
Expand a JSON array into rows
Iterate array elements using a table-valued function.
json_each✓ Tested
Generate a bounded integer range
JavaScript: Array.from supplies each output position to its mapping function.
JavaScript✓ Tested