元组与记录

发布于 2024-10-03 02:10:41 字数 18 浏览 8 评论 0原文

元组和记录有什么区别?

What is difference between tuples and records?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

锦上情书 2024-10-10 02:10:41

两者都是产品类型,可让您从多个更简单的类型构建类型。有些语言将元组视为一种记录。

定义

元组是一组有序的元素,例如 (10, 25)。

记录通常是一组命名元素,例如 { "x": 10, "y": 25 },其中值有两个标记为 xy 的字段,字段x的值为10

词源

“元组”一词来自“五元组”、“六元组”、“七元组”、“八元组”上常见的“-tuple”后缀,分别表示 5、6、7 和 8 的组。

“记录”一词来自数据表。您可以将具有 xy 字段的所有可能元组视为一个表,其中列对应于字段,行收集特定记录实例的所有字段。

 value address     field x    field y
 0xABCD            10         25
 0x1234            42         "xyz"

产品类型的等效性

您可以将元组视为一种记录,其中元组中元素的索引是其在等效记录中的名称,因此 (10, 25){ “0”:10,“1”:25 }。我相信标准机器学习和相关语言使用记录作为类型连词 (代数数据类型提供类型析取)并以这种方式将元组视为一种记录。

Both are product types which let you build types from multiple simpler types. Some languages treat tuples as a kind of record.

Definitions

A tuple is an ordered group of elements, like (10, 25).

A record is typically a group of named elements like { "x": 10, "y": 25 } where the value has two fields labelled x and y and the value of field x is 10.

Etymology

The word "tuple" comes from the common "-tuple" suffix on "quintuple", "sextuple", "septuple", "octuple" which mean groups of 5, 6, 7, and 8 respectively.

The word "record" comes from data tables. You can think of all possible tuples with x and y fields as a table where columns correspond to fields and rows collect all the fields for a particular record instance.

 value address     field x    field y
 0xABCD            10         25
 0x1234            42         "xyz"

Equivalence of product types

You can treat a tuple as a kind of record, where the index of an element in a tuple is its name within the equivalent record, so (10, 25) is { "0": 10, "1": 25 }. I believe Standard ML and related languages use records as the basic unit of type conjunction (algebraic data types provide type disjunction) and treat tuples as a kind of record in this way.

相对绾红妆 2024-10-10 02:10:41

根据维基百科:

在计算机科学中,记录也称为元组或结构)是最简单的数据结构之一,由存储在连续内存中的两个或多个值或变量组成职位;这样每个组件(称为记录的字段或成员)都可以通过对起始地址应用不同的偏移量来访问。

我想说元组和记录之间没有什么区别。

According to Wikipedia:

In computer science, a record (also called tuple or struct) is one of the simplest data structures, consisting of two or more values or variables stored in consecutive memory positions; so that each component (called a field or member of the record) can be accessed by applying different offsets to the starting address.

I would say there is little difference between a tuple and a record.

旧人 2024-10-10 02:10:41

记录是一个表的一整行数据元素,假设一个学生在卷号下有一条记录。 3 在一个表中,其中元组是记录的超集,其中数据也属于其他表,例如学生卷号 3 的记录行在其他表中的关系,即出勤、结果、联系人、费用等。所以,所有表中一个学生的全部数据集都是元组。据我所知。
谢谢。

Record is a complete row of data elements of one table, let say a student has a record under roll no. 3 in one table, where as tuple is a super set of record in which data belongs to other tables also, e.g. rows of records of student roll no.3 in other tables in relationship i.e. attendance, results, contacts, fees etc. So, that whole lot of data set of one student from all tables is tuple. As I know it.
Thanks.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文