For faster navigation, this Iframe is preloading the Wikiwand page for 多元组.

多元组

多元组,也称为顺序组(英语:Tuple),泛指有限个元素所组成的序列。在数学及电脑科学分别有其特殊的意义。

数学上,n元组多元组是对象个数有限序列。元组由三部分组成:边界符、分隔符和元素。通常采用的边界符是小括号“”,分隔符是逗号。

多元组被数学家用来描述包含特定部件的数学对象。例如,有向图被定义成一个二元组(V, E),这里V是节点的集合,EV × V的子集,表示边。

类型论中,多元组与重类别相关。

多元组的名称

长度为n的多元组通常称为n元组。二元组就是一个有序对n可以是任意正整数,例如,四元数就可以被表示成一个四元组。

形式定义

多元组区别于集合的主要性质在于:(1)它可以多次含有某个对象;(2)对象按照一定顺序出现。可以看到(1)使它区别于全序集,(2)使它区别于多重集。两个n元组的相等性通常以下列规则来表明:

(a1, a2, ...,an) = (b1, b2, ..., bn) 当且仅当 a1 = b1, a2 = b2, ..., an = bn

另一种形式化多元组的方式是将它们作为在集合论中更基本的构造,一个方法是利用有序对。例如,一个n元组(n > 1)能够定义成其第一项和由其他项组成的 (n−1)元组组成的有序对:

(a1, a2, ..., an) = (a1, (a2, ..., an))

采用有序对的一般集合论定义,并用空集来表示0元组,就可以得到下列归纳定义:

  1. 0元组用∅表示;
  2. xn元组(a1, a2, ..., an),则 (n + 1)元组(a, a1, a2, ..., an)等同于((a}, {a, x))。(n≥0)

采用这个定义,(1,2,2)为

(1,(2, (2))) = (1,(2, ((2}, {2, ∅)) )) = (1, ((2}, {2, ((2}, {2, ∅)))) ) = ((1}, {1, ((2}, {2, ((2}, {2, ∅))))))

这里与LISP最初使用有序对归纳地产生其所有的n元组和表结构的方法有非常重要的类似:

  1. 特殊符号NIL表示空表;
  2. X是一个表,A是任意值,则对 (A, X)表示一个表,其(第一个元素)为A,其(表中除了第一个元素的其他元素)为X

在电脑科学中的应用

电脑科学(特别是在程式设计语言数据库关系模型),多元组通常被定义为从字段名到特定值的有限函数(在此情况又可译为值组)。其目的和在数学中一样,就是指出特定的实体,或那些包含特定部件且(或)具有特定性质的对象。但是,这里的部件透过唯一的字段名来识别,而不是透过位置,这样通常会是更用户友好的记法。

多元组的例子:

(选手:"Harry", 分数:25)

就是一个映射字段名“选手”到字符串"Harry",映射字段名“分数”到数25的函数。注意,这里各个部件的顺序是不相关的,所以这个多元组也可以写成:

(分数:25, 选手:"Harry")

关系模型,一般以这样的多元组来表示一个简单命题,比如这个多元组的意思就是有一个选手的名字叫"Harry",他的分数是25。

在程式设计语言中,多元组被用来构建数据结构。例如,下列多元组可以表示双向链表中的一个节点:

(值:16, 前驱节点:1174782, 后继节点:1174791)
{{bottomLinkPreText}} {{bottomLinkText}}
多元组
Listen to this article

This browser is not supported by Wikiwand :(
Wikiwand requires a browser with modern capabilities in order to provide you with the best reading experience.
Please download and use one of the following browsers:

This article was just edited, click to reload
This article has been deleted on Wikipedia (Why?)

Back to homepage

Please click Add in the dialog above
Please click Allow in the top-left corner,
then click Install Now in the dialog
Please click Open in the download dialog,
then click Install
Please click the "Downloads" icon in the Safari toolbar, open the first download in the list,
then click Install
{{::$root.activation.text}}

Install Wikiwand

Install on Chrome Install on Firefox
Don't forget to rate us

Tell your friends about Wikiwand!

Gmail Facebook Twitter Link

Enjoying Wikiwand?

Tell your friends and spread the love:
Share on Gmail Share on Facebook Share on Twitter Share on Buffer

Our magic isn't perfect

You can help our automatic cover photo selection by reporting an unsuitable photo.

This photo is visually disturbing This photo is not a good choice

Thank you for helping!


Your input will affect cover photo selection, along with input from other users.

X

Get ready for Wikiwand 2.0 🎉! the new version arrives on September 1st! Don't want to wait?