Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to map multiple patterns in mapsubtrees? #74

Open
singularitti opened this issue Feb 6, 2023 · 3 comments
Open

How to map multiple patterns in mapsubtrees? #74

singularitti opened this issue Feb 6, 2023 · 3 comments

Comments

@singularitti
Copy link

Suppose I have a FileTree and two patterns: *.in for input files and *.out for output files. Usually, in the same folder, there will be two files: a *.in paired with a *.out. How can I match them at once in mapsubtrees? Like the following syntax:

mapsubtrees(tree, ("*.in", "*.out")) do (subtree1, subtree2)
    path(subtree1) => path(subtree2)
end
singularitti added a commit to MineralsCloud/ExpressDB.jl that referenced this issue Feb 6, 2023
@DrChainsaw
Copy link
Collaborator

This seems like a very useful function to have. I wonder if it will be difficult to have consistent semantics for the non-happy path cases.

For example, what should it do if the number of matches is not balanced (i.e number of matches for *.in is not the same as number of matches for *.out)?

Here is an example of what I usually do when I need to combine multiple files in the same dir: #51 (comment)

It does not have as convenient syntax as your example, but one can add that if needed. It is basically a map but only for directories which don't have subdirectories. For you example, you can then pick out the files matching your patterns from the argument passed to f (knowing they are in the same directory) and apply whatever function you need.

Reason why I have not put in into FileTrees is exactly that does not have consistent behaviour for all cases this package is supposed to handle.

@shashi
Copy link
Owner

shashi commented Feb 6, 2023

"*.(out|in)"? :)

@shashi
Copy link
Owner

shashi commented Feb 6, 2023

Oh i see what you mean.

I think you could do something like get the tree for the output, rename ".out" to ".in", and then merge the original .in tree with a function to combine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants