方案:将代码转换为图片

发布于 2024-09-27 16:42:59 字数 163 浏览 7 评论 0原文

我有一个奇怪的计划问题。这是我正在帮助朋友做的更大事情的一部分。

我需要将 Tree:Data 转换为准确表示树的图像(很抱歉,我还没有可以显示的示例图像)。

如果您对此有任何想法(和/或有疑问),请告诉我,以便我可以更新更多信息。

谢谢

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

无敌元气妹 2024-10-04 16:42:59

绘制此类图表的最常见方法之一是使用 graphviz。您只需要扫描树并以非常简单的语法打印出连接。

One of the most common ways to draw such diagrams is using graphviz. You just need to scan the tree and print out the connections in a very simple syntax.

浮光之海 2024-10-04 16:42:59

如果你真的、真的、真的必须直接在Scheme中完成它,那么让我在这里指导你:

http://www.gnu.org/software/mit-scheme/documentation/mit-scheme-ref/Drawing-Graphics.html

方案确实有一个内置的图形库,尽管这可能只是 MIT 方案所特有的。在伯克利,我们的入门课使用了 SICP,并且我们确实有图形,尽管这些图形是否是内置的,或者教师是否为我们添加了它们,我不太清楚。

If you really, really, really have to do it directly within Scheme, then let me direct you here:

http://www.gnu.org/software/mit-scheme/documentation/mit-scheme-ref/Drawing-Graphics.html

Scheme does indeed have a built-in graphics library, although this may be peculiar only to MIT Scheme. At Berkeley, our intro class used SICP, and we did have graphics somehow, although whether or not these graphics were built-in or whether the instructors added them for us, I'm not too clear on.

世界和平 2024-10-04 16:42:59

这就是我一直在寻找的答案。我想我应该更好地表达我的问题。无论如何,非常感谢@EliBarzilay 和@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)))

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)))
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文