Group Abstract Group Abstract

Message Boards Message Boards

0
|
11.8K Views
|
3 Replies
|
4 Total Likes
View groups...
Share
Share this post:

[?] Concatenate elements in a list?

Posted 8 years ago

I'm very new to Mathematica, so here comes a newbie question.

I have a list of numbers, such as {12,35}, and want to concatenate them to produce a single-element list: {1235} in this example. I then want to extract that element as an integer, 1235. Can someone please give me a clue.

Geoffrey Marnell

POSTED BY: Geoffrey Marnell
3 Replies

Thanks Christopher, thanks Patrick. Geoffrey Marnell

POSTED BY: Geoffrey Marnell

You can turn a number into a list of its digits using IntegerDigits. If you do that on all your numbers, you have a list where each element is a list of digits. Then you can Flatten this list to get one long list of digits. After that, you rebuild a new Integer.

FromDigits[Flatten[IntegerDigits[{12, 35}]]]

(* 1235 *)
POSTED BY: Patrick Scheibe
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard