What are considered atoms in Scheme?

后端 未结 2 1823
梦谈多话
梦谈多话 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 16:42

    The term "atom" is used by several authors (McCarthy and Friedman/Felleisen, among others) to refer to a datum that is not a "cons" pair. I claim that these days, you'd be more likely to invert that, and test for "cons"-hood rather than "atom"-hood. Where are you seeing the term used?

    0 讨论(0)
  • 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)))))
    
    0 讨论(0)
提交回复
热议问题