eq 之间的区别?和 = 在计划中? [英] Difference between eq? and = in Scheme?

查看:44
本文介绍了eq 之间的区别?和 = 在计划中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

    > (eq? 1 1)
    #t
    > (eq? 1.1 1.1)
    #f
    > (= 1.1 1.1)
    #t

这是 DrScheme 中的交互窗口.有人可以解释=和eq之间的区别吗?在方案中?

This is the interaction window in DrScheme. Could somebody please explain the difference between = and eq? in Scheme?

推荐答案

= 比较数字.等式?测试参数是否代表内存中的相同数据对象.等式?应该在第二种情况下工作,因为它测试与 eq 相同?但专门测试原语.更多关于方案中的等价谓词在这里.

= compares numbers. eq? tests if the parameters represent the same data object in memory. eqv? should work in the second case as it tests same as eq? but tests primitives specially. More on equlivence predicates in scheme here.

这篇关于eq 之间的区别?和 = 在计划中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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