Defining an operation such that ##1+2+3=123##

  • Context: High School 
  • Thread starter Thread starter Saracen Rue
  • Start date Start date
Click For Summary
SUMMARY

The discussion centers on defining a mathematical operation that concatenates numbers instead of adding them, exemplified by the equation ##12+34=1234##. This operation, known as concatenation, is commonly implemented in programming languages, particularly in C++ and Python, where the '+' symbol is used for both addition and string concatenation. The notation for this operation can be defined as \oplus : \mathbb{N}^2 \to \mathbb{N}, with specific rules for handling zero and the order of operations. The conversation also highlights the lack of a standardized symbol for concatenation across different fields.

PREREQUISITES
  • Understanding of basic mathematical operations and notation
  • Familiarity with programming concepts, particularly string manipulation
  • Knowledge of C++ and Python syntax for string concatenation
  • Basic understanding of mathematical functions and their properties
NEXT STEPS
  • Research the implementation of string concatenation in C++ and Python
  • Explore mathematical notation for defining custom operations
  • Learn about the associative and commutative properties of operations
  • Investigate the differences between numeric addition and string concatenation in programming languages
USEFUL FOR

Mathematicians, computer scientists, software developers, and anyone interested in the intersection of mathematics and programming, particularly in string manipulation and custom operations.

Saracen Rue
Messages
150
Reaction score
10
Firstly, I'm aware that title doesn't really make sense but stick with me on this. I'm trying to find a way to define an operation which will "join" two numbers instead of adding them. So for example, ##12+34=1234##. Ideally, it would be great if it also had something similar to sigma notation, like so:
$$\sum_{k=1}^{n} k= 12345...n$$

I'm sure this is actually something trivial that has been defined before, but I was finding it really difficult to search it up on Google (apparently "addition but instead of adding numbers just clomp together" doesn't yield very good results). So yeah, if anyone can tell me a better way to name this sort of maths it'd be greatly appreciated.
 
Mathematics news on Phys.org
This is called concatenation. You often have to program this kind of operation for strings or text.
 
  • Like
Likes   Reactions: berkeman, fresh_42, jedishrfu and 2 others
In computer languages, this is often done but there is no standardized symbol that would be universally recognized in other fields. Since C++ is such a well-established language, it might be the best thing to mimic. It uses the plus '+' symbol. The trick would be to distinguish it from numerical addition. Consider using quotes to make it clear that you are treating the number as a text string: "12"+"34"="1234".
If this is to appear in a document, you should clearly define your notation and symbology in the document.
 
  • Like
Likes   Reactions: topsquark
I suppose you have \oplus : \mathbb{N}^2 \to \mathbb{N} : (a,b) \mapsto \begin{cases} 10^{1 + \lfloor\log_{10}(b)\rfloor}a + b, &amp; b \neq 0, \\ 10a, &amp; b = 0\end{cases} which (if it does what I think it does) is associative but not commutative, and you need to decide whether <br /> \bigoplus_{n=0}^N a_n means a_0 \oplus a_1 \oplus \cdots \oplus a_N or a_N \oplus a_{N-1} \oplus \cdots \oplus a_0.
 
  • Like
Likes   Reactions: malawi_glenn and PeroK
In some computer languages, the addition operator took on different meaning dependent on the datatypes of items being added. It acted as normal addition for numeric types and as a concatenation operator for string types.

There were some purists who complained that since concatentation is not commutative that the addition operator shouldn't serve that function. However, using the addition operator for concatenation had become a defacto standard and was here to stay.

In Python, one can concat in several different ways:

- string1 + string2
- " ".join(string1, string2)
- ...

https://www.geeksforgeeks.org/python-string-concatenation/

and here's a larger set of multi language string concatentation examples:

https://en.wikipedia.org/wiki/Comparison_of_programming_languages_(string_functions)#Concatenation
 
  • Like
  • Informative
Likes   Reactions: berkeman, PeroK and FactChecker

Similar threads

  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 6 ·
Replies
6
Views
3K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 8 ·
Replies
8
Views
2K
  • · Replies 12 ·
Replies
12
Views
2K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 29 ·
Replies
29
Views
4K
  • · Replies 1 ·
Replies
1
Views
5K