What are considered atoms in Scheme?

后端 未结 2 1828
梦谈多话
梦谈多话 2020-12-16 16:08

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.

2条回答
  •  青春惊慌失措
    2020-12-16 17:01

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

    • Numbers
    • Strings
    • Symbols
    • Booleans
    • Characters

    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)))))
    

提交回复
热议问题