Open ym-han opened 3 years ago
Can't find it either.
@sashi, should it be in there? From the description it seems a bit similar to mapsubtrees
but I can't tell for sure if it should do the same thing.
@DrChainsaw wrong sashi, was it supposed to be for @shashi ?
Uups, forgot that there are more than three people using this platform :)
Any updates?
Did mapsubtrees(f, t, p)
or mapvalues(f, t[p])
work for you?
Unfortunately I don't have access to the docsite so I won't be able to push updates to it. This should maybe be fixed in the long run. It has been less of an issue than it might seem since the package has a pretty stable API.
How do I give you access to the docsite? I thought it's just a branch here?
Did
mapsubtrees(f, t, p)
ormapvalues(f, t[p])
work for you?
I am sorry, but as far as I understand, mapsubtrees
returns FileTrees
, right? What I need is "applying f
to every match". And mapmatches
seems to accept more types. I currently cannot run mapsubtrees
since the example in the doc is not a valid Julia example:
t = maketree("dir"=>([string(j)=>[(name=string(i), value=(i,j)]
for i=1:2] for j=1:3]
t1 = mapsubtrees("*") do subtree
reducevalues(vcat, subtree)
end
@shashi : Not sure either what is needed. Whenever I push the doc job fails. Unfortunately the logs have expired but I'm pretty certain it is some kind of "unauthenticated" failure. Perhaps it is just some secret that needs to be configured.
Currently the docs seem to be hosted in some domain which has your name in it (http://shashi.biz/). Perhaps things will just work if I point to the github pages. Let me know if this is ok with you.
@singularitti
I am sorry, but as far as I understand, mapsubtrees returns FileTrees, right?
Yes, all map functions return a FileTree.
What I need is "applying f to every match".
This is exactly what the map-functions do. You need to select the appropriate map function depending on what you want f
to have as input:
map
=> f
is given nodes (File
s or FileTree
s or just File
s if dirs=false
) and is expected to return a File
or FileTree
.mapvalues
=> f
is given the value attached to a node and is expected to return a new value (which may have any type) for that nodemapsubtrees
=> f
is given nodes (File
s or FileTree
s or just File
s if dirs=false
) and may return either nodes or just values.Both map
and mapvalues
work on the entire tree they are given, so there is no need for them to have a pattern argument. Just apply it to the tree before providing it (e.g. mapvalues(f, mytree[r"somepattern"]))
).
the example in the doc is not a valid Julia example
Uuups! This needs to be fixed of course.
Here is a valid example in the meantime:
julia> t = maketree("dir"=>([string(j)=>[(name=string(i), value=(i,j)) for i=1:2] for j=1:3]))
dir/
├─ 1/
│ ├─ 1 (Tuple{Int64, Int64})
│ └─ 2 (Tuple{Int64, Int64})
├─ 2/
│ ├─ 1 (Tuple{Int64, Int64})
│ └─ 2 (Tuple{Int64, Int64})
└─ 3/
├─ 1 (Tuple{Int64, Int64})
└─ 2 (Tuple{Int64, Int64})
julia> mapsubtrees(t, r"[1,3]") do st
reducevalues(vcat, st)
end
dir/
├─ 1/ (2-element Vector{Tuple{Int64, Int64}})
├─ 2/
│ ├─ 1 (Tuple{Int64, Int64})
│ └─ 2 (Tuple{Int64, Int64})
└─ 3/ (2-element Vector{Tuple{Int64, Int64}})
Currently the docs seem to be hosted in some domain which has your name in it (http://shashi.biz/).
that's just because shashi.github.io is aliased to shashi.biz... It would be possible to serve it on a different domain though.
I think the way Franklin works has changed. Need to update the github action.
The docs at http://shashi.biz/FileTrees.jl/patterns/ mention the function
mapmatches
, but that doesn't actually seem to be available. But I could be missing something really simple.