[racket] I don't understand structural recursion.

From: Damien Lee (charlicon at gmail.com)
Date: Sat Sep 17 18:19:59 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?
My appologies.

I find it quite difficult to draw trees using ASCII characters, but for 
the case when N = 1, there is only one such tree,


When N=2, there are two structurally distinct trees,

    .  and  .
  /             \
.               .

I'm told to output the results in "dotted parenthesised notation" which 
for the tree examples above looks like this,

((.).) and (.(.))

For N=3 the dotted parenthesised notation goes like this,


I have a function that takes a tree and emits this notation, but I thought it best to abstract the data into a
structure for more interesting output formats later.

I hope that helps, and thank you for looking,


Posted on the users mailing list.