Concatenating Lists: Associative but Not Commutative/Idempotent

  • MHB
  • Thread starter Kenan1
  • Start date
In summary, the conversation discussed the concepts of concatenation, associativity, and commutativity in relation to lists. It was explained that concatenation is the combination of two lists, while an operation is associative if the order of combining the lists does not matter. It was also noted that commutativity refers to the order of the lists not affecting the outcome. The examples given showed that concatenation is not commutative nor idempotent, and that it is associative.
  • #1
Kenan1
1
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
  • #2
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"?
 

FAQ: Concatenating Lists: Associative but Not Commutative/Idempotent

What is concatenation?

Concatenation is the process of combining two or more lists or strings together to create a new list or string.

What does it mean for concatenation to be associative?

Associative means that the order in which the lists are concatenated does not affect the final result. In other words, (A+B)+C is equal to A+(B+C).

Why is concatenation not commutative?

Concatenation is not commutative because the order in which the lists are concatenated does affect the final result. In other words, A+B is not necessarily equal to B+A.

What does it mean for concatenation to be idempotent?

Idempotent means that when a list is concatenated with itself, the result is the same as the original list. In other words, A+A is equal to A.

How is concatenation used in programming?

Concatenation is commonly used in programming to combine strings or lists together to create a new data structure. It is often used in data manipulation and string formatting.

Similar threads

Replies
6
Views
4K
Replies
9
Views
1K
Replies
1
Views
1K
Replies
12
Views
693
Replies
1
Views
619
Back
Top