uce/site/doc/pages/2_DValue_map.txt
2026-06-15 21:42:50 +00:00

21 lines
607 B
Plaintext

:sig
DValue DValue::map(std::function<DValue (const DValue& item, String key)> f) const
:params
f : mapper called for each iterated item
return value : mapped copy
:see
0_DValue
2_DValue_each
2_DValue_filter
:content
Builds a new `DValue` by replacing each iterated child with the mapper's returned value. List-shaped input stays list-shaped and is re-indexed by `push()`. Map-shaped input preserves keys. Scalar input is mapped once and pushed into a list.
```cpp
DValue labels = rows.map([](const DValue& row, String) {
DValue out; out = row.get_by_path("label").to_string(); return(out);
});
```