【问题标题】:Mozart-Oz difference between String and Atom字符串和原子之间的莫扎特-奥兹区别
【发布时间】:2019-03-11 18:09:37
【问题描述】:

谁能简要解释 Oz 编程语言中 String 和 Atom 类型之间的区别?我发现缺少文档。

【问题讨论】:

  • 如果我没记错的话sting是一个包含字符的列表,而atom是一个空记录(有标签但没有组件的记录)。

标签: types oz mozart


【解决方案1】:

这是 CTM 书中显示的类型层次结构。

据此,原子是一种记录。与其他类型的记录不同,原子没有内部结构。字符串只是列表的语法糖,因此将具有列表的所有其他属性,例如以Head|Tail 表示,以nil 结尾,等等。

你可以尝试这两个例子来加深你的理解:

{Browse 'hello'==hello} % prints true, neither is a string

{Browse "hello"==[104 101 108 108 111]} % prints true, equivalent representations of the same string

{Browse 'hello'=="hello"} % prints false

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-05-10
    • 2014-06-08
    • 1970-01-01
    • 2017-01-29
    • 1970-01-01
    • 1970-01-01
    • 2018-07-20
    • 2013-05-26
    相关资源
    最近更新 更多