# Persistent Red Black Tree in Lisp (2)

### Single rotate

Using the kid utility, we can make rotate single to be simpler too:

Observe that the two return form is nested reversed. Why not write a macro that generate this form? Then we only need to write the right case!

### Reverse the tree

First we need to write a function that take a nested form and return it in reversed order (also nested.) To achieve this, we use double recursion.

Recall that we need to add list at the beginning of returned form. So rewrite the function as

### Macro that simplify the return form

Now we write a macro that we only need to pass it the right case:

Now the insert-binary-r and rotate-s can be re-written only in right form!

### Macro that simplify the input form

We also want to simplify that ugly let form, so we create this function and macro:

And then you can rewrite rotate-s:

See? We don’t need to write the comment to remind us the relative position of variables. The code express itself! You can see what this code will expand to by expanding the macro: