Hi Lee,
I don't understand a thing in your first code * scratches head * (cause of the passing variables between the subfunctions and aswell they use recursions), but the important is that it works.
Good job, you brought me the nostalgia - back when I was lisp newbie and you still were providing overwhelming solutions.
Atleast I understood the iterative version.
This function is handy for experimenting with tables (generating/manipulating).