You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This would be a new operation like select and transform. For now this is just an idea to brainstorm and is related to the old idea #49
find-paths would find specific paths to each element matched by the path. So (find-paths [ALL :a] [{:a 1} {:a 2}]) would return something like [(path (nthpath 0) :a) (path (nthpath 1) :a)].
A use case this would help with is merging two data structures together, like two lists of lists of maps. find-paths could be used so that a transform could be done on one element while querying the other data structure for the other element. The exact semantics needed by find-paths in order to do this are so far unclear. Another issue to consider for this use case is that during the merge, each sublist should be descended into a single time, whereas iterating through individual element paths will re-traverse the same parts of the data structure repeatedly.
More use cases are needed in order to understand the precise semantics find-paths should have.
The text was updated successfully, but these errors were encountered:
Another possibility to consider rather than find-paths are versions of select and transform that also compute element-specific paths as they go – select-with-paths and transform-with-paths.
Well one use case that is very obvious, but not currently covered by Specter is merging two datastructures. For a use-case imagine you're making something like https://github.com/weavejester/meta-merge. So you're merging two nested datastructures and at each point where they differ you need to have a mechanism to inspect the difference (including inspecting metadata) to decide how to merge them. It would be also useful for ORMs style software for unrolling nested data structures into a sequence of INSERT, DELETE, UPDATE operations.
This would be a new operation like
select
andtransform
. For now this is just an idea to brainstorm and is related to the old idea #49find-paths
would find specific paths to each element matched by the path. So(find-paths [ALL :a] [{:a 1} {:a 2}])
would return something like[(path (nthpath 0) :a) (path (nthpath 1) :a)]
.A use case this would help with is merging two data structures together, like two lists of lists of maps.
find-paths
could be used so that atransform
could be done on one element while querying the other data structure for the other element. The exact semantics needed byfind-paths
in order to do this are so far unclear. Another issue to consider for this use case is that during the merge, each sublist should be descended into a single time, whereas iterating through individual element paths will re-traverse the same parts of the data structure repeatedly.More use cases are needed in order to understand the precise semantics
find-paths
should have.The text was updated successfully, but these errors were encountered: