On 6/24/2009 2:02 PM, Mike Beddo wrote:
Greetings!

Can someone provide a simple script for a R function that recursively builds a 
binary tree. I am most familiar with C and pass by reference, but I think R is 
like Fortran and pass by value.


Here's a tree with a random depth:

makeTree <- function() {
    if (runif(1) < 0.4) list(makeTree(), makeTree())
    else "leaf"
}

Duncan Murdoch

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to