Mike Beddo
2009-Jun-24 18:02 UTC
[R] How to recursively build a binary tree with R script?
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. - Mike Beddo
Duncan Murdoch
2009-Jun-24 18:52 UTC
[R] How to recursively build a binary tree with R script?
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