Concatenating Lists: Associative but Not Commutative/Idempotent

  • Context: MHB 
  • Thread starter Thread starter Kenan1
  • Start date Start date
Click For Summary
SUMMARY

The discussion clarifies that list concatenation is an associative operation but not commutative or idempotent. Given lists A = "abcd" and B = "1234", the concatenation results in AB = "abcd1234", demonstrating associativity through the equation (AB)C = A(BC). However, the commutative property fails as AB ≠ BA, exemplified by AB = "abcd1234" and BA = "1234abcd". The discussion emphasizes the importance of understanding these properties in the context of list operations.

PREREQUISITES
  • Understanding of list data structures
  • Familiarity with the concepts of concatenation and string manipulation
  • Knowledge of mathematical properties: associative, commutative, and idempotent
  • Basic programming skills to implement list operations
NEXT STEPS
  • Research the implementation of list concatenation in Python
  • Explore the differences between associative and commutative operations in programming
  • Learn about idempotent operations in functional programming
  • Investigate the performance implications of list concatenation in various programming languages
USEFUL FOR

Students, software developers, and computer science enthusiasts looking to deepen their understanding of list operations and their mathematical properties.

Kenan1
Messages
1
Reaction score
0
Hallo guys,
I'm looking for your help :). Here is a question from an Assigment, that i should tomorrow gave.

Explain that the concatenation of lists is associative but not commutative and not idempotent. (In this respect, there is one thing in common, however, two differences from the union.) Use as a symbol for the concatenation
K..L for lists K and L.
Thanks in Advance!
 
Physics news on Phys.org
Do you understand what "concatenation", "associative", and "commutative" mean? Given two lists, say A= "abcd" and B= "1234" their "concatenation" is AB= "abcd1234".

An operation is "associative" if (AB)C= A(BC). The differences are that, on the left, we combine A and B first, then add C to that. On the right, we combine B and C first, then add A to that.

An operation is "commutative" if AB= BA. That is, it does not matter which we have on the left and right.

Suppose A= "abcd" and B= "1234". Then AB= "abcd1234" and BA= "1234abcd". Are those the same string? Is concatenation "commutative"?

Suppose A= "abcd", B= "1234", and C= "x5y9z". Then AB= "abcd1234" so (AB)C= "abcd1235x5y9z" while BC= "1234x5y9z" so A(BC)= "abcd1234x5y9z". Are those the same string? Is concatenation "associative"?

- - - Updated - - -

Do you understand what "concatenation", "associative", and "commutative" mean? Given two lists, say A= "abcd" and B= "1234" their "concatenation" is AB= "abcd1234".

An operation is "associative" if (AB)C= A(BC). The differences are that, on the left, we combine A and B first, then add C to that. On the right, we combine B and C first, then add A to that.

An operation is "commutative" if AB= BA. That is, it does not matter which we have on the left and right.

Suppose A= "abcd" and B= "1234". Then AB= "abcd1234" and BA= "1234abcd". Are those the same string? Is concatenation "commutative"?

Suppose A= "abcd", B= "1234", and C= "x5y9z". Then AB= "abcd1234" so (AB)C= "abcd1235x5y9z" while BC= "1234x5y9z" so A(BC)= "abcd1234x5y9z". Are those the same string? Is concatenation "associative"?

- - - Updated - - -

Do you understand what "concatenation", "associative", and "commutative" mean? Given two lists, say A= "abcd" and B= "1234" their "concatenation" is AB= "abcd1234".

An operation is "associative" if (AB)C= A(BC). The differences are that, on the left, we combine A and B first, then add C to that. On the right, we combine B and C first, then add A to that.

An operation is "commutative" if AB= BA. That is, it does not matter which we have on the left and right.

Suppose A= "abcd" and B= "1234". Then AB= "abcd1234" and BA= "1234abcd". Are those the same string? Is concatenation "commutative"?

Suppose A= "abcd", B= "1234", and C= "x5y9z". Then AB= "abcd1234" so (AB)C= "abcd1235x5y9z" while BC= "1234x5y9z" so A(BC)= "abcd1234x5y9z". Are those the same string? Is concatenation "associative"?
 

Similar threads

  • · Replies 7 ·
Replies
7
Views
2K
  • · Replies 7 ·
Replies
7
Views
2K
  • · Replies 17 ·
Replies
17
Views
3K
  • · Replies 3 ·
Replies
3
Views
1K
  • · Replies 3 ·
Replies
3
Views
1K
  • · Replies 48 ·
2
Replies
48
Views
8K
  • · Replies 6 ·
Replies
6
Views
4K
  • · Replies 9 ·
Replies
9
Views
2K
  • · Replies 1 ·
Replies
1
Views
1K
  • · Replies 12 ·
Replies
12
Views
2K