21 lines
607 B
Plaintext
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);
|
|
});
|
|
```
|