R/tupelList.R

Defines functions tupels

tupels<- function(dims){
		n <- length(dims)
		lastDimIndeces <-  1:dims[[n]]
		if(n==1){
				tupels <- lastDimIndeces
		}else{
				others <- tupels(dims[1:(n-1)])
				tupels <- list()
		    for (i in lastDimIndeces){
					tupels <-append(tupels,lapply(others,function(tup){
						newtup <- c(tup,i)
						return(newtup)
				 }))
				}
		}	
		return(tupels)
}
test <- tupels(c(2,3,4))

Try the SoilR package in your browser

Any scripts or data that you put into this service are public.

SoilR documentation built on Oct. 13, 2023, 5:06 p.m.