I found this loop can do this. is there any simple method?

rm(list=ls())
a=c(2,3,5,7)
mylist=list(c(2,3),5,7)

newlist=list()
for (i in 1:4){
  for (j in 1:length(mylist)){
     newlist[[j]]=mylist[[j]]
     if (a[i] %in% mylist[[j]]){
        newlist[[j]]=mylist[[j]][mylist[[j]]!=a[i]]
        if (length(newlist[[j]])==0){
           newlist[[j]]=NA
        }
     }
  }
  print(newlist[!is.na(newlist)])
}

	[[alternative HTML version deleted]]

