如何在方案中列出评估的所有中间步骤 [英] How to list all intermediate steps of evaluation in Scheme

查看:54
本文介绍了如何在方案中列出评估的所有中间步骤的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

例如,如果有表达式:

(map (lambda(x) (add1 x)) '(1 2 3))

其评估结果为:

'(2 3 4)

如何显示所有中间步骤,在这种情况下将是:

How to display all the intermediate steps which in this case will be:

(map (lambda(x) (add1 x)) '(2 2 3))
(map (lambda(x) (add1 x)) '(2 3 3))

推荐答案

我认为,做到这一点的最佳方法是从制作自己的lambda演算解释器开始,并添加所需的额外方案功能,然后修改该解释器.生成所需的执行跟踪.

I think the best way to do this would be to start by making your own lambda calculus interpreter and adding the extra scheme features you need, and then modifying that interpreter to produce the execution trace that you want.

这可以帮助您开始编写解释器 http://matt.might.net/articles/implementing-a-programming-language/

This could get you started with writing an interpreter http://matt.might.net/articles/implementing-a-programming-language/

这篇关于如何在方案中列出评估的所有中间步骤的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆