closure property of datatype “tuple” in python

From this link, below is the slide that I would like to understand:

The Closure Property of Data Types

  • A method for combining data values satisfies the closure property if:
  • The result of combination can itself be combined using the same method.
  • Closure is the key to power in any means of combination because it permits us to create hierarchical structures.
  • Hierarchical structures are made up of parts, which themselves are made up of parts, and so on.

Tuples can contain tuples as elements

In math, we know that,

The closure property of real number addition states that when we add real number to other real number the result is also real. For example, 3 + 6 = 9 .

I think the above slide also talks about tuple on these same lines.

My question:

As per above slide,

  1. Like addition in case of real numbers, what is the operation on which tuple hold closure property?

  2. Can you explain how the closure property(only) of tuple permits hierarchical structures? Because as per this code, it is “closure property + recursive property” of a data model permits a data model to be hierarchical.

2

Mathematical definition: Closure is defined for a particular operation over a particular set. Let’s say we had a set S and we have 2 elements from S, call them a and b, and we have an operation, call it @ that combines 2 elements of S. Then @ is closed over S if a@b is always in S, no matter which particular elements we picked.

So you have to specify both an operation and a set if you want to be perfectly clear about what is meant by ‘closure’. (Sometimes people omit one or both if they think context makes it clear enough what they mean.)

In programming, types often show up where in math you’d expect a set. You can think of a type as the set of all possible values of that type, and a value being of a particular type as that value belonging to the corresponding set.

With that background: the operation in this case is tupling (making a tuple) and the set/type over which we have closure is the set of tuples. For instance, (a,b) and (c,d) are tuples, and combining them makes another tuple: ((a,b), (c,d)).

The important thing to get from that slide is not the word ‘closure’ or even its mathematical definition, but that nestable data structures are powerful.

11

At the risk of repeating the previous solid, deleted answer…

Like addition in case of real numbers, what is the operation on which tuple hold closure property?

This is an odd question. There are infinitely many operations that work on tuple (or any type for that matter), which will return some type that the operation can be applied to again. It’s like asking which sentence ends in the letter L.

Can you explain how the closure property(only) of tuple permits hierarchical structures? Because as per this code, it is “closure property + recursive property” of a data model permits a data model to be hierarchical.

You’re taking things too literally.

Recursion is not necessary for closure. Closure does not necessarily provide hierarchical structures. Consider this simple function:

 T Identity(){ return this; }

Hopefully it is clear that this provides the necessary property that you can take the result of the function and perform the function on it again. But it is not recursive, and it is not hierarchical. It isn’t a “combination”, but it’s trivial to add a parameter which is then discarded.

What the slide is trying to convey is that the closure property is a very useful pattern. Having an object that is itself the same type as its parts is well known in the OO world as the composite pattern. In functional languages, they are more often known as algebraic data types (though they’re so common there, that they often aren’t given a special name).

And it is powerful because it provides a concise way to define infinite, fractal-like structures like lists and trees that are the foundation of data structures; and by extension, a foundation of computing.

2

There’s no just ‘closure propery’, there’s a ‘closure under operation X‘. For instance, integers are closed both under addition and multiplication.

Tuples are closed under many operations, one of them being ‘element composition’, that is, you can use a tuple as an element of another tuple. This particular property obviously, by construction, allows to build recursive structures. Compare it to nodes in a tree.

There are other operations under which tuples are also closed, e.g. ‘merging’ of tuples (expressed by +) that do not allow for arbitrary recursive structures, but allow theoretically arbitrary length, etc.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa

closure property of datatype “tuple” in python

From this link, below is the slide that I would like to understand:

The Closure Property of Data Types

  • A method for combining data values satisfies the closure property if:
  • The result of combination can itself be combined using the same method.
  • Closure is the key to power in any means of combination because it permits us to create hierarchical structures.
  • Hierarchical structures are made up of parts, which themselves are made up of parts, and so on.

Tuples can contain tuples as elements

In math, we know that,

The closure property of real number addition states that when we add real number to other real number the result is also real. For example, 3 + 6 = 9 .

I think the above slide also talks about tuple on these same lines.

My question:

As per above slide,

  1. Like addition in case of real numbers, what is the operation on which tuple hold closure property?

  2. Can you explain how the closure property(only) of tuple permits hierarchical structures? Because as per this code, it is “closure property + recursive property” of a data model permits a data model to be hierarchical.

2

Mathematical definition: Closure is defined for a particular operation over a particular set. Let’s say we had a set S and we have 2 elements from S, call them a and b, and we have an operation, call it @ that combines 2 elements of S. Then @ is closed over S if a@b is always in S, no matter which particular elements we picked.

So you have to specify both an operation and a set if you want to be perfectly clear about what is meant by ‘closure’. (Sometimes people omit one or both if they think context makes it clear enough what they mean.)

In programming, types often show up where in math you’d expect a set. You can think of a type as the set of all possible values of that type, and a value being of a particular type as that value belonging to the corresponding set.

With that background: the operation in this case is tupling (making a tuple) and the set/type over which we have closure is the set of tuples. For instance, (a,b) and (c,d) are tuples, and combining them makes another tuple: ((a,b), (c,d)).

The important thing to get from that slide is not the word ‘closure’ or even its mathematical definition, but that nestable data structures are powerful.

11

At the risk of repeating the previous solid, deleted answer…

Like addition in case of real numbers, what is the operation on which tuple hold closure property?

This is an odd question. There are infinitely many operations that work on tuple (or any type for that matter), which will return some type that the operation can be applied to again. It’s like asking which sentence ends in the letter L.

Can you explain how the closure property(only) of tuple permits hierarchical structures? Because as per this code, it is “closure property + recursive property” of a data model permits a data model to be hierarchical.

You’re taking things too literally.

Recursion is not necessary for closure. Closure does not necessarily provide hierarchical structures. Consider this simple function:

 T Identity(){ return this; }

Hopefully it is clear that this provides the necessary property that you can take the result of the function and perform the function on it again. But it is not recursive, and it is not hierarchical. It isn’t a “combination”, but it’s trivial to add a parameter which is then discarded.

What the slide is trying to convey is that the closure property is a very useful pattern. Having an object that is itself the same type as its parts is well known in the OO world as the composite pattern. In functional languages, they are more often known as algebraic data types (though they’re so common there, that they often aren’t given a special name).

And it is powerful because it provides a concise way to define infinite, fractal-like structures like lists and trees that are the foundation of data structures; and by extension, a foundation of computing.

2

There’s no just ‘closure propery’, there’s a ‘closure under operation X‘. For instance, integers are closed both under addition and multiplication.

Tuples are closed under many operations, one of them being ‘element composition’, that is, you can use a tuple as an element of another tuple. This particular property obviously, by construction, allows to build recursive structures. Compare it to nodes in a tree.

There are other operations under which tuples are also closed, e.g. ‘merging’ of tuples (expressed by +) that do not allow for arbitrary recursive structures, but allow theoretically arbitrary length, etc.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa

closure property of datatype “tuple” in python

From this link, below is the slide that I would like to understand:

The Closure Property of Data Types

  • A method for combining data values satisfies the closure property if:
  • The result of combination can itself be combined using the same method.
  • Closure is the key to power in any means of combination because it permits us to create hierarchical structures.
  • Hierarchical structures are made up of parts, which themselves are made up of parts, and so on.

Tuples can contain tuples as elements

In math, we know that,

The closure property of real number addition states that when we add real number to other real number the result is also real. For example, 3 + 6 = 9 .

I think the above slide also talks about tuple on these same lines.

My question:

As per above slide,

  1. Like addition in case of real numbers, what is the operation on which tuple hold closure property?

  2. Can you explain how the closure property(only) of tuple permits hierarchical structures? Because as per this code, it is “closure property + recursive property” of a data model permits a data model to be hierarchical.

2

Mathematical definition: Closure is defined for a particular operation over a particular set. Let’s say we had a set S and we have 2 elements from S, call them a and b, and we have an operation, call it @ that combines 2 elements of S. Then @ is closed over S if a@b is always in S, no matter which particular elements we picked.

So you have to specify both an operation and a set if you want to be perfectly clear about what is meant by ‘closure’. (Sometimes people omit one or both if they think context makes it clear enough what they mean.)

In programming, types often show up where in math you’d expect a set. You can think of a type as the set of all possible values of that type, and a value being of a particular type as that value belonging to the corresponding set.

With that background: the operation in this case is tupling (making a tuple) and the set/type over which we have closure is the set of tuples. For instance, (a,b) and (c,d) are tuples, and combining them makes another tuple: ((a,b), (c,d)).

The important thing to get from that slide is not the word ‘closure’ or even its mathematical definition, but that nestable data structures are powerful.

11

At the risk of repeating the previous solid, deleted answer…

Like addition in case of real numbers, what is the operation on which tuple hold closure property?

This is an odd question. There are infinitely many operations that work on tuple (or any type for that matter), which will return some type that the operation can be applied to again. It’s like asking which sentence ends in the letter L.

Can you explain how the closure property(only) of tuple permits hierarchical structures? Because as per this code, it is “closure property + recursive property” of a data model permits a data model to be hierarchical.

You’re taking things too literally.

Recursion is not necessary for closure. Closure does not necessarily provide hierarchical structures. Consider this simple function:

 T Identity(){ return this; }

Hopefully it is clear that this provides the necessary property that you can take the result of the function and perform the function on it again. But it is not recursive, and it is not hierarchical. It isn’t a “combination”, but it’s trivial to add a parameter which is then discarded.

What the slide is trying to convey is that the closure property is a very useful pattern. Having an object that is itself the same type as its parts is well known in the OO world as the composite pattern. In functional languages, they are more often known as algebraic data types (though they’re so common there, that they often aren’t given a special name).

And it is powerful because it provides a concise way to define infinite, fractal-like structures like lists and trees that are the foundation of data structures; and by extension, a foundation of computing.

2

There’s no just ‘closure propery’, there’s a ‘closure under operation X‘. For instance, integers are closed both under addition and multiplication.

Tuples are closed under many operations, one of them being ‘element composition’, that is, you can use a tuple as an element of another tuple. This particular property obviously, by construction, allows to build recursive structures. Compare it to nodes in a tree.

There are other operations under which tuples are also closed, e.g. ‘merging’ of tuples (expressed by +) that do not allow for arbitrary recursive structures, but allow theoretically arbitrary length, etc.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật