Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

This question already has an answer here:

I have nested-lists in number format,like

 data={{1,2,3},{2,{3,4,50}},{4,5,6},{3,{3,{5,6}}}}

I want to convert each number into String format.For that purpose I tried the following code,but it doesn't working.

case1 :

 stringData=ReplaceAll[data, Identity -> String]

case2:

stringData= MapAll[ToString, data]

Testcase 1:

Part[stringData, 1, 2] + 10

I evaluated testcase,but it showing 12.

How can I solve this?

feel free,If you want to edit my question.

share|improve this question

marked as duplicate by Oleksandr R., Jens, Sjoerd C. de Vries, Yves Klett, m_goldberg Mar 15 '13 at 13:47

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1  
Look at the docs for ToString. –  whuber Mar 14 '13 at 16:25

2 Answers 2

Does Map like this

Map[
 ToString[#] &,
 {{1, 2, 3}, {2, {3, 4, 50}}, {4, 5, 6}, {3, {3, {5, 6}}}},
 {-1}
 ]

do what you want?

share|improve this answer
2  
Why do you use ToString[#] &, instead of just ToString? –  Sjoerd C. de Vries Mar 14 '13 at 16:35
1  
@SjoerdC.deVries to annoy MrW with my lack of brevity :) –  acl Mar 14 '13 at 16:38
    
@acl Ah, then why not Function[string, ToString[string]][#]& :P –  rm -rf Mar 14 '13 at 17:16
    
@rm-rf He ought then to prefer ToString[#] & @# &@# &@# &@# &@# &@# &@# &@# &@# &. Oh, sorry, that's too compact: how about ToString[#] &[#] &[#] &[#] &[#] &[#] &[#] &[#] &[#] &[#] &[#] & instead? :-) –  whuber Mar 14 '13 at 17:21
1  
Oh gads, I've been sniped. I was about to comment on the unnecessary Function in ToString[#] & and then I saw the comments. I hate you for the next 13.7 minutes. ;-p –  Mr.Wizard Mar 14 '13 at 18:42

Building on your first try, an alternative to acl's approach is

l = {{1, 2, 3}, {2, {3, 4, 50}}, {4, 5, 6}, {3, {3, {5, 6}}}};
ReplaceAll[l, n_Integer :> ToString[n]]

which gives

{{"1", "2", "3"}, {"2", {"3", "4", "50"}}, {"4", "5", "6"}, {"3", {"3", {"5", "6"}}}}
share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.