Created
May 15, 2019 14:45
-
-
Save SimonDanisch/64c3b0a36d3a2981fb3404b7115ee89e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function searchmodule(mod, name, visited = Set()) | |
mod in visited && return nothing | |
push!(visited, mod) | |
string(mod) == string(name) && return mod | |
if mod isa Module | |
name == nameof(mod) && return mod | |
for sym in names(mod) | |
res = searchmodule(getfield(mod, sym), name, visited) | |
res !== nothing && return res | |
end | |
end | |
return nothing | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment