Search code examples
schemecode-visualization

Scheme: Convert Code to picture


I have a weird Scheme question. This is a part of something bigger that I'm helping a friend with.

I need to convert a Tree:Data into an image that accurately represents the tree (I'm sorry I don't have a sample image to show just yet).

Please let me know if you have any ideas for this (and/or if you have questions) so I can update with more information.

Thank you


Solution

  • This is the answer I was looking for. I guess I should have articulated my question a little better. Thank you very much for the help anyways, @EliBarzilay and @KevinHwang

    (define (Tree:Data->Pict dt)
      (if (DataTree? dt)
          (frame
           (vl-append 10
                      (Tree:Data->Pict (DataTree-data dt))
                      (apply ht-append 10
                             (map Tree:Data->Pict (DataTree-children dt)))))
          (code #,dt)))