cleanup, docs
This commit is contained in:
@@ -6,6 +6,7 @@ f : mapper called for each iterated item
|
||||
return value : mapped copy
|
||||
|
||||
:see
|
||||
>types
|
||||
0_DValue
|
||||
2_DValue_each
|
||||
2_DValue_filter
|
||||
@@ -13,8 +14,11 @@ return value : mapped copy
|
||||
: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);
|
||||
});
|
||||
```
|
||||
:example
|
||||
DValue names;
|
||||
DValue first; first = "ada";
|
||||
DValue second; second = "grace";
|
||||
names.push(first);
|
||||
names.push(second);
|
||||
DValue upper = names.map([](const DValue& item, String key) { DValue out; out = to_upper(item.to_string()); return(out); });
|
||||
print(upper["0"].to_string(), ",", upper["1"].to_string(), "\n");
|
||||
|
||||
Reference in New Issue
Block a user