Results for “Ownership & optional values”
Small, practical examples. Search by task or narrow things down below.
Sum integer values
Sum a C# sequence using LINQ.
C#✓ Tested
Sum integer values
Reduce a Java integer stream to its sum.
Java✓ Tested
Sum numeric values
Provide an initial accumulator for JavaScript reduce, including empty arrays.
JavaScript✓ Tested
Sum typed values with reduce
Accumulate numeric array elements.
reduce✓ Tested
Sum values per category
Calculate a grouped total.
SUM✓ Tested
Sum vector values
Use std::accumulate with a wide initial value.
C++✓ Tested
Take a limited number of iterator values
Python: Use islice to consume only the requested prefix of a potentially unbounded iterator.
Python✓ Tested
Test whether any or all values match
C#: Any and All short-circuit instead of materializing filtered collections.
C#✓ Tested
Transform an optional value
Java: Use Optional.map and orElse to transform a possibly absent result.
Java✓ Tested
Transform array values
Use map to create a JavaScript array of squared values.
JavaScript✓ Tested
Turn known group values into columns
SQL: Conditional aggregation gives a portable pivot when the category set is known.
SQL✓ Tested
Turn known group values into columns
SQL Server: Conditional aggregation gives a portable pivot when the category set is known.
SQL Server✓ Tested