Results for “library”
Small, practical examples. Search by task or narrow things down below.
Store a value in a named variable
Python: Give a value a descriptive name and print it.
Python✓ Tested
Store a value in a named variable
Java: Give a value a descriptive name and print it.
Java✓ Tested
Store an object associated with an element
jQuery: data retains JavaScript values without serializing them into HTML attributes.
jQuery✓ Tested
Store data in an enum variant
Store data in an enum variant in a complete Rust program using the standard library.
Rust✓ Tested
Subtract durations without underflow
Subtract durations without underflow in a complete Rust program using the standard library.
Rust✓ Tested
Sum array values
Iterate over a fixed C array using a size-derived element count.
C✓ Tested
Sum integer values
Reduce a Java integer stream to its sum.
Java✓ Tested
Sum vector values
Use std::accumulate with a wide initial value.
C++✓ Tested
Swap two integers
Use a temporary value to swap C integers without arithmetic overflow.
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
Take a page from a stream
Java: Use skip and limit with a known stable input order.
Java✓ Tested
Take an immutable list snapshot
Java: List.copyOf protects the snapshot from later changes to the source list.
Java✓ Tested