Results for “map”
Small, practical examples. Search by task or narrow things down below.
Keep only the most recent items
Python: Use a bounded deque to discard the oldest item as new values arrive.
Python✓ Tested
Parse only valid integers
Parse only valid integers in a complete Rust program using the standard library.
Rust✓ Tested
Read an optional dictionary key
Python: Use get with a fallback while leaving the dictionary unchanged.
Python✓ Tested
Read complete lines into an array
Bash Scripts: Mapfile with -t removes each line terminator but preserves other whitespace.
Bash Scripts✓ Tested
Remove an entry and inspect its value
Remove an entry and inspect its value in a complete Rust program using the standard library.
Rust✓ Tested
Remove and return a dictionary entry
Python: Use pop with a default when a missing entry is an expected condition.
Python✓ Tested
Represent a set with empty structs
Represent a set with empty structs using a complete Go program with explicit sample inputs.
Go✓ Tested
Transform a collection into a plain array
jQuery: map followed by get returns ordinary JavaScript values.
jQuery✓ Tested
Transform an observable value
Transform an observable value with a standalone Angular component and explicit browser behavior.
Angular✓ Tested
Transform an optional value
Java: Use Optional.map and orElse to transform a possibly absent result.
Java✓ Tested
Transform an optional value
Transform an optional value in a complete Rust program using the standard library.
Rust✓ Tested
Transform array values
Use map to create a JavaScript array of squared values.
JavaScript✓ Tested