什么是 Scheme 中的原子? [英] What are considered atoms in Scheme?

查看:40
本文介绍了什么是 Scheme 中的原子?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以向我解释或链接到任何可以帮助我理解原子是什么的有用资源(我在谷歌上找不到任何主题).

Can someone please explain or link me to any helpful resources ( I couldn't find any threads on google) that could help me understand what atoms are.

推荐答案

如今,我们将 atom 视为不是 cons-pair 且不为 null 的元素.这包括:

Nowadays we consider an atom an element that's not a cons-pair and that is not null. That includes:

  • 数字
  • 字符串
  • 符号
  • 布尔值
  • 字符

最好通过以下程序来表达这一点,摘自 The Little Schemer 一书中:

This is best expressed with the following procedure, taken from the book The Little Schemer:

(define atom?
  (lambda (x)
    (and (not (pair? x)) (not (null? x)))))

这篇关于什么是 Scheme 中的原子?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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