Add support for applying a function to every variable within a CodimensionalCollection #3
Labels
No labels
bug
duplicate
enhancement/documentation
enhancement/feature
enhancement/organization
question
rejected
upstream
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
UserCurt/collections-toolbox#3
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
It would be quite convenient to apply a function to all variables within a CodimensionalCollection at the same time, returning a new CodimensionalCollection as a result. For example, one could perform
mean(C)which would apply themeanfunction to each entry of the CodimensionalCollectionC. Of course, not all methods can be known in advance, especially whenCcontains custom classes with custom methods, so it may be better to define anapplymethod:The name
applyis not settled. Alternatives to consider includemap,transform,foreach. Thoughforeachdoesn't suggest it returns a value so is probably not a good choice.It may be appropriate to also apply to only a subset of variables. The
applymethod cannot be overloaded to account for this as it would be ambiguous whether any additional arguments should be passed in or not. Instead, a new function likeapplySubsetcould be made that that applies a mapping to a subset of variables. However, it would be unclear whether it keeps the others intact or omits them. It may be more appropriate to instead of aselectmethod that selects a subset of variables and then subsequently usingapply. This is out of scope for this feature request, but it could influence whether a method likeapplySubsetis developed or not.