[racket] I don't understand structural recursion.

From: Damien Lee (charlicon at gmail.com)
Date: Sat Sep 17 18:23:16 EDT 2011

On 17/09/11 23:04, Nadeem Abdul Hamid wrote:
> Do you have some examples? Concrete examples of possible input values
> and what you expect the corresponding output to look like? And if the
> function expects integers as input, then what is the difference in the
> output between two successive input values like 2 and 3? 4 and 5? 0
> and 1?

I forgot to mention, I believe the difference between success node 
values corresponds to the Catalan numbers. I'm not certain of this, I 
just have a function that I believe outputs the number of distinct 
sequences, which the OEIS claimed was the Catalan sequence 

(define (num-distinct-btrees N)
(if (<= N 1)
(λ (Np)
(* (num-distinct-btrees (- Np 1))
(num-distinct-btrees (- N Np))))
(build-list N add1))))

(define (accumulate f list)
(if (empty? list)
(+ (f (car list))
(accumulate f (cdr list)))))


Posted on the users mailing list.