another noob recursion question

2011-12-01 Thread John Holland
I've been looking into Clojure and now Scheme for a while. Currently it's been SICP. I notice that SICP has examples of recursion such as a binary tree builder that is something like the following: (define (tree top elements split-value) (cons (tree (filter ( split-value) elements) )

Re: another noob recursion question

2011-12-01 Thread David Nolen
On Thu, Dec 1, 2011 at 7:03 AM, John Holland jbholl...@gmail.com wrote: I've been looking into Clojure and now Scheme for a while. Currently it's been SICP. I notice that SICP has examples of recursion such as a binary tree builder that is something like the following: (define (tree top

Re: another noob recursion question

2011-12-01 Thread Stuart Sierra
Tree-building functions are not usually tail-recursive. I'm not even sure that Scheme will do tail-call elimination in that case. The Java stack can hold 8000 frames or so, so log base 2 is probably small enough to avoid a stack overflow when building a tree. You could probably rewrite this

Re: another noob recursion question

2011-12-01 Thread Alan Malloy
On Dec 1, 2:14 pm, Stuart Sierra the.stuart.sie...@gmail.com wrote: Tree-building functions are not usually tail-recursive.  I'm not even sure that Scheme will do tail-call elimination in that case.  The Java stack can hold 8000 frames or so, so log base 2 is probably small enough to avoid a