What is the most efficient way to concatenate two positive integers in Mathematica 7?
cc[123, 4567]
>> 1234567
What about more than two?
cc[123, 4, 567, 89]
>> 123456789
This will be slightly faster for many integers, than your last solution:
ToExpression[StringJoin @@ Map[IntegerString, {##}]] &
A more concise alternative is to accept a single argument, assuming it to be a list, rather than a sequence, of numbers to concatenate:
ToExpression@StringJoin@IntegerString@#&
which is based on IntegerString
being Listable
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With