Access elements in list of list

I am able to get elements for a list of lists.
How can I get using a loop as I want to use in another loop?
Thanks

library(rlist)
mat3 <- combn(1:5, 3)
mat2<- combn(1:5, 2)
list2=split(mat2, rep(1:ncol(mat2), each = nrow(mat2)))
list3=split(mat3, rep(1:ncol(mat3), each = nrow(mat3)))

mylist=list.append(list3,list2)

mylist

for(i in 1:10){
  print(mylist[[i]])
}
for(j in 1:10){
  print(mylist[[11]][[j]])
}

# but the following is probably better than a loop
purrr::walk(mylist,function(x){if(is.list(x)) purrr::walk(x,print) else print(x)})

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.