22 lines
		
	
	
		
			435 B
		
	
	
	
		
			R
		
	
	
	
	
	
			
		
		
	
	
			22 lines
		
	
	
		
			435 B
		
	
	
	
		
			R
		
	
	
	
	
	
#' Recursive Map
 | 
						|
#'
 | 
						|
#' @examples
 | 
						|
#' RMap(paste,
 | 
						|
#'     list("a", list("b", "c", list("d", "e")), "f"),
 | 
						|
#'     list("A", list("B", "C", list("D", "E")), "F"),
 | 
						|
#'     list(10, list(20), 30),
 | 
						|
#'     1:3,
 | 
						|
#'     "X"
 | 
						|
#' )
 | 
						|
#'
 | 
						|
#' @export
 | 
						|
RMap <- function(f, ...) {
 | 
						|
    Map(function(...) {
 | 
						|
        if (any(unlist(Map(is.recursive, list(...))))) {
 | 
						|
            RMap(f, ...)
 | 
						|
        } else {
 | 
						|
            match.fun(f)(...)
 | 
						|
        }
 | 
						|
    }, ...)
 | 
						|
}
 |