Created
February 28, 2024 13:45
-
-
Save jrosell/faa0e59c9e0bd1db27f37ae0f0f9710f 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
library(tidyverse) | |
x <- list(a = list(b = 1, c = NULL), d = NULL) | |
get_list_names <- \(x, y = c()){ | |
if (!is.null(names(x))){ | |
for (nm in names(x)) { | |
y <- get_list_names(x[[nm]], c(y, nm)) | |
} | |
} | |
return(y) | |
} | |
get_list_names(x) | |
"c" %in% get_list_names(x) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment