How to take list to number?
up vote
1
down vote
favorite
I have a list such as:
a = {1, 2, 4, 3};
and I want to get the 'number' of the list. For this example, I want to get this number: 1243
. I do not know how to get it easily. For now, my solution is:
a[[1]]*10^3+a[[2]]*10^2+a[[3]]*10^1+a[[4]];
It works. But it is too complex. I want to know a way more convenient.
functions special-functions
New contributor
add a comment |
up vote
1
down vote
favorite
I have a list such as:
a = {1, 2, 4, 3};
and I want to get the 'number' of the list. For this example, I want to get this number: 1243
. I do not know how to get it easily. For now, my solution is:
a[[1]]*10^3+a[[2]]*10^2+a[[3]]*10^1+a[[4]];
It works. But it is too complex. I want to know a way more convenient.
functions special-functions
New contributor
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I have a list such as:
a = {1, 2, 4, 3};
and I want to get the 'number' of the list. For this example, I want to get this number: 1243
. I do not know how to get it easily. For now, my solution is:
a[[1]]*10^3+a[[2]]*10^2+a[[3]]*10^1+a[[4]];
It works. But it is too complex. I want to know a way more convenient.
functions special-functions
New contributor
I have a list such as:
a = {1, 2, 4, 3};
and I want to get the 'number' of the list. For this example, I want to get this number: 1243
. I do not know how to get it easily. For now, my solution is:
a[[1]]*10^3+a[[2]]*10^2+a[[3]]*10^1+a[[4]];
It works. But it is too complex. I want to know a way more convenient.
functions special-functions
functions special-functions
New contributor
New contributor
edited 1 hour ago
Αλέξανδρος Ζεγγ
3,6431927
3,6431927
New contributor
asked 1 hour ago
user61054
161
161
New contributor
New contributor
add a comment |
add a comment |
4 Answers
4
active
oldest
votes
up vote
2
down vote
a={1,2,4,3};
FromDigits[a]
(* 1234 *)
add a comment |
up vote
1
down vote
Other than the built-in FromDigits
, we can build our wheel
Fold[{10, 1}.{##} &, a]
add a comment |
up vote
0
down vote
Best way would be to use build-in function FromDigits
as shown above.
But just in case you'd like a convoluted way to do it, here is another option
a = {1, 2, 4, 3};
ToExpression[StringJoin[ToString[#] & /@ a]]
add a comment |
up vote
0
down vote
These are some methods I would not recommend:
lst = {1, 2, 3, 4};
f = (Curry[StringRiffle][""] /* ToExpression);
g = (Through[{
Identity,
Length /* Range /* Reverse /* Curry[Plus][-1] /* Curry[Power, 2][10]
}[#]] & /* MapThread[Times] /* Total);
f[lst] (* 1234 *)
g[lst] (* 1234 *)
add a comment |
4 Answers
4
active
oldest
votes
4 Answers
4
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
a={1,2,4,3};
FromDigits[a]
(* 1234 *)
add a comment |
up vote
2
down vote
a={1,2,4,3};
FromDigits[a]
(* 1234 *)
add a comment |
up vote
2
down vote
up vote
2
down vote
a={1,2,4,3};
FromDigits[a]
(* 1234 *)
a={1,2,4,3};
FromDigits[a]
(* 1234 *)
answered 1 hour ago
Mike Honeychurch
30.8k268143
30.8k268143
add a comment |
add a comment |
up vote
1
down vote
Other than the built-in FromDigits
, we can build our wheel
Fold[{10, 1}.{##} &, a]
add a comment |
up vote
1
down vote
Other than the built-in FromDigits
, we can build our wheel
Fold[{10, 1}.{##} &, a]
add a comment |
up vote
1
down vote
up vote
1
down vote
Other than the built-in FromDigits
, we can build our wheel
Fold[{10, 1}.{##} &, a]
Other than the built-in FromDigits
, we can build our wheel
Fold[{10, 1}.{##} &, a]
answered 1 hour ago
Αλέξανδρος Ζεγγ
3,6431927
3,6431927
add a comment |
add a comment |
up vote
0
down vote
Best way would be to use build-in function FromDigits
as shown above.
But just in case you'd like a convoluted way to do it, here is another option
a = {1, 2, 4, 3};
ToExpression[StringJoin[ToString[#] & /@ a]]
add a comment |
up vote
0
down vote
Best way would be to use build-in function FromDigits
as shown above.
But just in case you'd like a convoluted way to do it, here is another option
a = {1, 2, 4, 3};
ToExpression[StringJoin[ToString[#] & /@ a]]
add a comment |
up vote
0
down vote
up vote
0
down vote
Best way would be to use build-in function FromDigits
as shown above.
But just in case you'd like a convoluted way to do it, here is another option
a = {1, 2, 4, 3};
ToExpression[StringJoin[ToString[#] & /@ a]]
Best way would be to use build-in function FromDigits
as shown above.
But just in case you'd like a convoluted way to do it, here is another option
a = {1, 2, 4, 3};
ToExpression[StringJoin[ToString[#] & /@ a]]
answered 17 mins ago
Nasser
57.1k486205
57.1k486205
add a comment |
add a comment |
up vote
0
down vote
These are some methods I would not recommend:
lst = {1, 2, 3, 4};
f = (Curry[StringRiffle][""] /* ToExpression);
g = (Through[{
Identity,
Length /* Range /* Reverse /* Curry[Plus][-1] /* Curry[Power, 2][10]
}[#]] & /* MapThread[Times] /* Total);
f[lst] (* 1234 *)
g[lst] (* 1234 *)
add a comment |
up vote
0
down vote
These are some methods I would not recommend:
lst = {1, 2, 3, 4};
f = (Curry[StringRiffle][""] /* ToExpression);
g = (Through[{
Identity,
Length /* Range /* Reverse /* Curry[Plus][-1] /* Curry[Power, 2][10]
}[#]] & /* MapThread[Times] /* Total);
f[lst] (* 1234 *)
g[lst] (* 1234 *)
add a comment |
up vote
0
down vote
up vote
0
down vote
These are some methods I would not recommend:
lst = {1, 2, 3, 4};
f = (Curry[StringRiffle][""] /* ToExpression);
g = (Through[{
Identity,
Length /* Range /* Reverse /* Curry[Plus][-1] /* Curry[Power, 2][10]
}[#]] & /* MapThread[Times] /* Total);
f[lst] (* 1234 *)
g[lst] (* 1234 *)
These are some methods I would not recommend:
lst = {1, 2, 3, 4};
f = (Curry[StringRiffle][""] /* ToExpression);
g = (Through[{
Identity,
Length /* Range /* Reverse /* Curry[Plus][-1] /* Curry[Power, 2][10]
}[#]] & /* MapThread[Times] /* Total);
f[lst] (* 1234 *)
g[lst] (* 1234 *)
answered 5 mins ago
Shredderroy
1,4181115
1,4181115
add a comment |
add a comment |
user61054 is a new contributor. Be nice, and check out our Code of Conduct.
user61054 is a new contributor. Be nice, and check out our Code of Conduct.
user61054 is a new contributor. Be nice, and check out our Code of Conduct.
user61054 is a new contributor. Be nice, and check out our Code of Conduct.
Thanks for contributing an answer to Mathematica Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
Use MathJax to format equations. MathJax reference.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f187524%2fhow-to-take-list-to-number%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown