I have a recursive function. The recursion forms a tree with many (millions) terminal nodes. The function must output a value (say, a number or a vector) from each terminal node. At the end, when all recursion is done, we want to collect all the output values. How can that be done cleanly and efficiently?
A prototype example is a recursive function that generates all permutations of a vector (or simply of 1:n). One permutation is generated at each terminal node. Terminal nodes occur at various depths in the tree. We don't need to pass anything up the tree, just output from the terminal nodes. Is there a way to create a global data structure and have a function tack data onto that structure? sort of like the C++ pushback()? One solution is to output values to a file, and at the end read the file back. This worked ok, but is there a better way? _________________________________________________________________ Live. ______________________________________________ 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.